[Solved] Restart level + losing lives conundrum

Hi again. So I have, at the begining of the scene lives = 50
i want when player dies restart scene, so obviously the lives counter never gets down.
any work-around ideas? thanks

Just set the global variable Lives to 50, and don’t reset it at the beginning of the scene.

If you have a title/start screen of some kind, you could also set it to 50 there, and that way it will only reset to 50 when the entire game (not just the level) is restarted.

1 Like

just set it as a isolated condition or action right? i’ve done that but then it doesn’t show 50 at the counter when you start the level

Beanmatt’s solution is good!
If you don’t have a title/start screen and/or if you can’t set the global variable’s value to 50 any other way, I think this would also work:

I hope this helps!

thank you, yeah tried that before, doesn’t work :frowning:

I’m sorry. : ( I’m quite confused as to why.

If you did all that and it didn’t work I think your problem may not be restarting the scene, but something else. Maybe the variable isn’t getting 1 subtracted from it at all?

Could you try removing the “Change scene” action for now and stay in the scene just to see if the variable’s value is reduced at all?

Sorry if you’ve already done that, I’m really blanking otherwise.

The logic in GDev is read from top to bottom, so in your example the logic that removes lives is not getting a chance to run.

Try moving the action to remove lives to above the scene change/reset.


I meant can you go into Game Settings > Global Variables and set Lives to 50 there? That way, each time you start the game it will start at 50.


no need to apologize, you are helping me :slight_smile: i haven’t done that. It is subtracting if i delete the restart.

oooh man yeah, didn’t know that! works perfectly, solved! thank you