Forum Discussion

thelivinglegend0's avatar
5 months ago
Solved

OnPlayerEnterWorld CodeBlockEvent not firing

Hi all, I'm having an issue with the OnPlayerEnterWorld event not firing in my world.

Here's my code snippet: 

import * as hz from 'horizon/core';

class TestScript extends hz.Component<typeof TestScript> {
  static propsDefinition = {};

  start() {
    console.log("Hello world!")
    this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterWorld, (player : hz.Player) => {
      console.log("HEY THE PLAYER JOINED THE WORLD!");
    })
  }
}
hz.Component.register(TestScript);


I can see the "Hello World" String in the console, but I do not see the "HEY THE PLAYER JOINED THE WORLD!" string after I click the "Enter Preview Mode" button in the editor. I attached this TestScript to an empty game object in my world, and I have the script executing in "Default" mode.

I'm not sure what I'm doing wrong here. I'd appreciate any advice!

 

  • I figured the issue out. One of my other scripts had a runtime error and it seems like it was preventing some of my other scripts from firing certain events.

1 Reply

  • I figured the issue out. One of my other scripts had a runtime error and it seems like it was preventing some of my other scripts from firing certain events.