So I'm developing a 2D retro platform where you have 3 lives. Every time you lose a life you start from the beginning of the level. If you lose all your lives you start from the beginning of the game. I tried to create a life var in the player but every time the level restarts it's script restart too. Does anyone know a better way to do it? I'm a beginner in programming so it is not one of my strengths.

If you want to reload the level and keep the current lives of the player then you can use a singleton.

2 years later

The video from this guy is very confusing, because he keeps putting code up & creating singletons & then deleting them & putting them back. Why can't he just go through step by step to explain how to actually create a project with 3 lives, like the person who ask the question actually ask for? I think he just likes to show off his coding skills.

2 years later