Save the score to next scene [SOLVED]

Hi. I have a problem with saving the score. What I want to do is restart the score in the same scene when you die but save it for the next one.

For example. In the first level, you got 50 points but you died before finish it. So you went back to start of the level with 0 points. If you finish the level with 50 points, you start the second level with 50 points. If you die in the second level you go back the start of the second level with 50 points. And this is going on for next levels.

I tried to use Global Variables but the problem is when you die with 50 points it starts with 50 points again. I can make “Do = 0 Global Variable Score” but only for first level. Can’t do it in next ones.

So this is my problem and thank you for reading it.

You have to use both types of variables:

  • A global variable “Score”, that saves the total score.
  • A scene variable “score”, that saves the current scene score.
    You can call them the same, I will call the global score with uppercase and scene score with lowercase.

Now the idea is to increase the score in the scene variable, this way when you reset the scene, this score is 0 again. But when you finish the scene, before switching to the next one, add the value of the scene score to the global score :slight_smile:

[code]Conditions: At the beginning of the scene
Actions: Do = 0 to the variable “score” (optional, variables are = 0 by default anyway)

Conditions: Conditions to add score
Actions: Do + 5 to variable “score”

Conditions: Conditions to lose
Actions: Change the scene to “CurrentSceneName”

Conditions: Conditions to win
Actions: Do + Variable(score) to the global variable “Score”
Change the scene to “NextSceneName”[/code]

If you want to show the global score to the player, you’ll have to show:

GlobalVariable(Score) + Variable(score)

Because this is the current total score :wink:

Thank you so much. It works. I also added some things. You saved the day again :slight_smile: