How do I make my character "die" and go to a "home screen"?

I need help with my code to make a “lose 1 health” and the when they die they have a screen come up, and then you have to go to home.

var Losehealth = pc.createScript('losehealth');

Losehealth.attributes.add('st1 health',{type : "entity"});

Losehealth.attributes.add('nd2 health',{type : "entity"});

Losehealth.attributes.add('rd3 health',{type : "entity"});

Losehealth.attributes.add('death',{type : "entity"});

Losehealth.attributes.add('touch',{type : "entity"});

let Lost = 0;


if((Touch == true)) {

Lost += 1;


if (Lost == 1) {

this.St1health.enabled = false;


if (Lost == 2) {

this.Nd2health.enabled = false;


if (Lost == 3) {

this.Rd3health.enabled = false;

this.Death.enabled = true;



I just need a script that can disable the health entity and then when the health runs out, your game stops, than you have a death screen.

@Kyle_3_1415 There are numerous ways to do this but here is one idea. In your Losehealth script you can monitor for the player health inside of the update function. Once you reach the point of zero call another function that activates another scene which contains only the death screen and possibly a button to restart the game. Here is a tutorial on how to use scene switching so you have an example.

I am not sure what other scripts or scenes are in your game currently. Maybe you could share your project so others can have a look.