Forum Discussion

Exo_Guid's avatar
Exo_Guid
MHCP Partner
11 months ago
Solved

Async SetInterval Issue (spawned asset)

I'm trying to have a loop on a spawned object.  When it's spawned it's sent and receives: const spawnAssetEvent = new CodeBlockEvent<[player: Player]>('setup', [PropTypes.Player]);   I've connec...
  • Exo_Guid's avatar
    11 months ago

    I created a manager object that does a list of activespawns and only sends the message to items on the list.  I changed my code and moved the gettickEvent inside the spawnAssetEvent to assure this.player was set.

      start() {
        this.SPAWNMANAGER = this.props.SPAWNMANAGER!;
        const spawnAssetEvent = new CodeBlockEvent<[player: Player]>('setup', [PropTypes.Player]);
       
        this.connectCodeBlockEvent(this.entity, spawnAssetEvent, (player: Player) => {
          this.player = player
          this.initialize();
          this.sendCodeBlockEvent(this.SPAWNMANAGER, registerSPAWNED, this.entity);
          this.connectCodeBlockEvent(this.entity, getTickEvent, this.worldtick.bind(this));
        });
    
    ///gives ownership errors on Default

    What ultimately fixed my issue was changing my script execution from Local to Default.  yay emote?