Making a high score system in my game

So recently, I decided to try and add a high score system to my game, so I watched some tutorials on youtube. Everything was going well, but it became apparent that they were outdated, as the storage actions in all the tutorials that I watched didn’t match the ones in my version of Gdevelop. So I’m wondering if there’s a newer way to use the storage system to save my high scores?

So here are some events that I tried creating. I used save and load a value in the place of write and read a value respectively.

Yeh I think save and load a value (or text if it’s text) is right. But it should probably look more like this.

Unless you really need an extra scene variable HighScore. But you can call a global variable from any scene, so I’m not sure why you would.

Also I’m not sure you need a trigger once, I just put it there to keep the events from constantly running, and assuming it is like a start or level select screen where you want to display a high score. If it’s in the actual game play you can trigger it on whatever you want, like Player dies and score is better than high score or something.

I tried arranging my events similar to yours, but that didn’t work, and I’ve gone back to my previous layout. My current issue is that the high score won’t save and/or load when I play a second time. Other than that everything works fine.

Also I’m pretty sure you don’t need trigger once in this particular case, since your just changing the high score to the value of your score. You only need it if you’re increasing the value by a specific amount (such as for instance, if you have an action that says add 10).

Ok just using your 2 events with no kind of condition or anything to trigger them to stop. But I did put a 1 second limit on them to run.

You wouldn’t need a trigger once for the event where you compare 2 numbers, if you then added an action to change Global HighScore set to Global Score. Because then the condition wouldn’t be true any more.

But instead you change a Scene HighScore variable. So global HighScore remains less than Score (so it’s probably saving correctly in your events, you’re just not changing it to a value that needs to be saved) and these actions repeat over and over. Needlessly repeat, because as you point out, the values are not changing.

I have a HighScore of 5 in my demo project. It is always 5. So there is really no reason this action should change my scene variable HighScore to 5 over and over again. How many times per second is it repeatedly changing scene variable HighScore set to global variable Score?

As you can see, it changed my scene variable HighScore to the value 5 a whopping 59 times in 1 second. And it needlessly saved my game 59 times a second. And changed the text box 59 times in 1 second.

HighScore text is still 0 because of the issue I mentioned in the second paragraph, and I’ve logged 178 console messages in 1 second.

So, if I’m understanding everything correctly here, your saying that the high score variable is changing too many times per second? Because I’ve added a trigger once condition to that event and made that event a sub event of my number comparison event and nothing has changed, even though I also turned my scene variables into global variables.

No that was a completely different thing related to your events before. They were running too much for no reason. They weren’t breaking anything since they were just putting the same value in over and over but too many events like that might make your game perform badly.

Now your events look really good. I don’t think you need the trigger once there. And the only thing you have to do is in your begin scene when you load 1 from storage and store it into a scene variable high_score - that is because you can’t store it directly into the global. So right after you load it from storage and put it into scene varible high_score, you want to add an event under that one in the same block to change global variable high_score set to scene variable high_score.

Oh also you can use the function to compare 2 numbers because both score and high score are numbers not text. Or you could just say global variable score > than global variable highscore and not use the compare 2 number. Unless you are storing your scores in text variables and not numbers, I see a lot of “string” going on.

So like this?