[SOLVED] Error when loading another scene

Hello everyone, i made a new script for the change button but when i click on it it says there is an error.

This is the code:

var Changebutton = pc.createScript('changebutton');
Changebutton.attributes.add('sceneName', {type: 'string'});

// initialize code called once per entity
Changebutton.prototype.initialize = function() {
    this.entity.button.once('click', function() {
        loadScene(this.sceneName, { hierarchy: true, settings: true });
    }, this);
};

This the error message

Hey,
Do you have a load scene helper script in your project where the loadScene method is defined?
If not, try pasting it from the official play canvas project: PlayCanvas 3D HTML5 Game Engine and your function should work as intended.

2 Likes

Hi, thx for helping the problem is solved now!