[SOLVED] Setter func on entity's script

Hi!
I have Root(Game) script wich do calculations for another entities. How can i pass value from root to another entity script.
I tried use passing in root atribute an another entity, and call it’s srtipts with parameters. But there is not correct function context.
For example:

Game.attributes.add('anotherEntity', { type: 'entity' });
Game.prototype.setToAnotherEntity = function() {
    const val = this.anotherEntity.script.setterFunc(this.someParams)
    console.log(val) // undefined
};
AnotherEntity.prototype.initialize= function() {
    this.inicializedVariable = "someValue";
    this.setTo = "initValue"
};
AnotherEntity.prototype.setterFunc= function(someParams) {
    this.setTo = someParams;
    return this.inicializedVariable;
};

AnotherEntity.prototype.update= function() {
    console.log(this.setTo) //  "initValue"
};

I tried bind context but it doesn’t work. Maybe I working with scripts not for the best way. Can you expaine how can i subscribe to changes in root from another entities? And important thing is i have to clone AnotherEntity, and pass this.someParams to current clone

That all should work unless it’s an order of initialisation issue. ie one script is initialising before the other so the values have not been set yet. You can get around this by also using postInitialize

Can you post an example project that shows this error please?

Thanks for answer!
There is a project PlayCanvas 3D HTML5 Game Engine
Problem in script game.js, line 125, this.arrowEntity.script.arrowThrow.setPoints(this.points).
This method calling, but if you’ll try to console.log(this.someVariableOrMethod) in setPoints it will be undefined

I don’t understand this step

It is worth noting in the Editor for Entity Arrow

The script component is disabled so the initialisation function of the script arrowThrow is not called

Method setPoints don’t see any valiables in scope of his prototype

That’s because the initialisation function hasn’t been called because the script component on the Entity is disabled. (See edited last post)

OMG, such a stupid mistake
It works well, Thanks a lot