[SOLVED] This.app.root not working in a function

Hello, in my project I have added a pause screen that can be accessed by pressing P (you also have to press escape to enable the cursor, if you know how to disable pointer lock w/ a script, I would appreciate it if you could let me know), and when you press the button in the middle of the screen labeled “resume_button” it should disable the pause_screen entity, making the button disappear. Unfortunately, this is not working. In my buttonLogic script, I put:

this.entity.button.on('click', function() {
        this.app.root.findByName("pause_screen").enabled = false;

This gives me an error which says: " Uncaught TypeError: Cannot read properties of undefined (reading ‘root’) "
Project: PlayCanvas | HTML5 Game Engine
Also, you’ll need to press escape again after trying to press the button, because it locks the cursor. I have no idea how to fix this, but for now that’s just what you’ll have to do to trigger the event.

Hi @cyron! This problem is the same as your problem with the timeout.


Solved, thank you!