Uncaught TypeError: Cannot read properties of undefined (reading 'play')

loading game scene for the first time works fine.

issue on the second time while loading the same game scene.
image

You will need to share some code/a project that shows the problem for the community to help more.

Offhand, it looks like you still have a reference to object from the scene that was destroyed instead of the one that is in the new scene that created

I took reference from these links -

Please verify if all the events are properly subscribed and unsubscribed in this script.

https://playcanvas.com/editor/code/935419?tabs=89036499

There issue is here:

    this.app.on('destroy', () => {

        this.setEventsOnOff('off');

        this.app.off('OnFinish', this.onFinish, this);
        this.app.off('OnCollect', this.onCollect, this);
        // this.app.off('OnObstacle', this.onObstacle, this);

        this.app.off('attr:loop', this.resetPosition, this);    
        this.app.off('attr:yoyo', this.resetPosition, this);  
        this.app.off('attr:delay', this.resetPosition, this);  
        this.app.off('attr:repeat', this.resetPosition, this);
        this.app.off('attr:easing', this.resetPosition, this);

        this.app.off('attr:duration', function (value) { this.tween.duration = value;}, this);

        this.menuButton.button.off('click', this.loadMenu, this);
        this.playButton.button.off('click', this.playGame, this);
    });

You are listening for the destroy event for the app, not the script type.

It should be:

this.on('destroy', () => {

The OnCollect event was never unsubscribed so when the bird collected something, it was calling an old listener.

Thankyou It worked.