How to simply Change scenes

umm, I need help with changing scenes, i have made a button with the function for when it is pressed, but how do i change scenes, the code is here.

https://playcanvas.com/editor/code/739251?tabs=38367126,38367331,38367479

i have seen the scene changing tutorial in playcanvas but i dont understand.

it isnt even a tutorial it just shows project and editor

press nextScene.js in the code editor

Yeah, they are project examples where we show the code and project layout. We are working to make it clearer which ones are tutorials and demo projects and will also long do more long form tutorials

ok, but how do i do the changing scene stuff?

There’s code in the project demo you referenced https://playcanvas.com/editor/project/437633

It comes down to understanding what is written in the code and comments: https://playcanvas.com/editor/code/437633?tabs=5632645

ok

i don’t know how to use the code in the way i want to.

but i think i get it now

myscript.prototype.initialize = function(){
     this.object = this.app.root.findByName('Yeet');
     this.object.button.on('mousedown',this.onclick,this);
};


myscript.prototype.onclick = function(){
    var oldHierarchy = this.app.root.findByName ('Root');
    
    // Get the path to the scene
    var scene = this.app.scenes.find(sceneName);
    
    // Load the scenes entity hierarchy
    this.app.scenes.loadSceneHierarchy(scene.url, function () {
            this.object.button.off('mousedown',this.onclick,this);
            oldHierarchy.destroy();
    });
};

ok, thx