How would I make a script that when a button is pressed certain entities would turn off/on

I want to make it to where when my button is pressed two of my entities turn on and off but I don’t know how I would do it

project https://playcanvas.com/editor/scene/1095201

Hello @deductedflame24
I think you have to make a small line in a script to say that other scripts can be accessed not only one.

what do you mean @Gabriel_Dobrzynski

Try make a small line in your script that will allow you lets say I want to pick a gun but make a small line of script to let you access other guns.

so like an attribute is what you mean

In your code that handle the button press you could do something like:

var entity = this.app.root.findByName ('MyEntity');  // use your actual entity name
if (entity) {
    entity.enabled = true;  // or false;
}
1 Like

Thank you @Kulodo133