[SOLVED] Cannot set property 'enabled' of null

Hi, so I’m trying to disable something after 1000ms. When trying to do so, it says ‘Cannot set property ‘enabled’ of null’. Here is the code:

        var screen4 = app.root.findByName('Frame').findByName('Screen4');
 
        app.on('game:start', function () {
            setTimeout(function () {
            screen4.enabled = false;
            }, 1000);
        }, this);

        app.fire('game:start');

I have no idea why this is happening, but please, any help to do this is appreciated :slight_smile:

Hey! Most likely the screen4 didn’t succeed finding the entity.

Try debugging the first line of your code, using breakpoints or console.log and check the value of the screen4 variable. If it didn’t check your names, and also take it step by step, check if the Frame entity was indeed found.

Thanks @Leonidas! This specific line was the problem. I changed it to this below and it fixed my problem.

var screen4 = app.root.findByName('Screen4');

:slight_smile:

1 Like