[Solved] Need help with Lives and game over

How can I make the global variable set it to Lives = 3 then even if scene restarts because of death it doesn’t reset to 3 then if player dies it loses 1 then if player lives is 0 go to scene Game Over Then IF they click restart it then finally resets to 3 again

I already have a global Var for Score and Lives made in properties

Instead of using “set variable to”, you need to subtract the value and then save it to the storage, since it’s a global variable, I suggest this video to get a good idea of it:

This is how I do it:


When the player dies, I subtract 1 from their lives, and then save the new value (Using “Save a text”) into a storage called “Progression1” (cause I have multiple save slots, you don’t have to worry about that if you have just one save)

This is when I open the pause menu and click restart, but it can also work at the beginning of the scene when you want to load up the value, instead of “Set lives to” just have it load the value (Using “Load a text”) that was saved when the player died, and since it’s a global variable, I use “Convert JSON to a global variable” action, although I’m not sure if the new update affected this since it’s now called “CONVERT JSON to a variable” but it still works for me so (I’m using a structure but normally what you would want to do is store the global variable “Lives”)
For that TemporaryVariable, just have a variable in the scene where you need the values to load, and have it like this

As for the names of the storage, that’s up to you

thanks hard to understand as i am new but i also need it to show 3 lives… also i dont have a pause screen just they lay dead 3 seconds then scene restart

Oh sorry I forgot that part, okay so we’re in the game over screen and we want the number to go back to 3 when we continue, so if the player presses continue/restart or whatever, just set the global variable to the default value you want (In this case 3, mine is 5) and then save that new variable like you did before

Using storage at this stage for what you are going is a bit overkill.

Here are some suggestions:

  1. Don’t set the global variable “Lives” at the start of the scene. Set it to 3 in the global variable editor. When the player dies and runs out of lives, then reset it to 3. But ideally it should be done in another scene that calls the game scene, like in a menu screen.

  2. Don’t Pause a scene and start a second scene unless you stop and resume from the second scene. For your case, you should change scene to “Level 1-1” when the player dies.

  3. Anything after change of scene action won’t get processed. Make the change scene the last action in an event. So the reducing lives and resetting score actions should be done before you change scene.

Fixed it now next goal make music continue after I un pause lol