[Solved] Save score as SOLD problem

Hello Gdevelop users, i have a little problem, wich i hope to solve it with your help,
I’m making a game where the points become sold for your wallet and are shown on main menu, the problem is that the sold that is shown on main menu is the last score that i make on lv1 scene. For Example, i play and make 1000 score, the sold on main scene become 1000, play again and make 500 score, the score on main scene is 1500, play again and make 100 score, the score on main scene is 1600, all good, BUT if i quit the game and enter again, the sold on main screen is 100, wich is the last score that i made on lv1 scene. here are some pictures with the code i wrote for achieve this.


1 Like

You save the scene/lvl Score and not the Scorglobal.

2 Likes

Can you be more specific? as the way i have it now, it works perfect if i not quit the game.

The part where you add the level score to the global variable is not visible on your screenshots.
You write the 100 to storage, not the 1500.

1 Like

first sceenshot is from lv1, i save the score and i read it from menu scene, if i use scene variable instead of global variable is not working. what is seen in the screnshots is all good for this to work. i dont know now how to make a variable that store sold, just to store it.

I don’t see how you add the result of lvl1 to the old wallet value before saving. So you save the current lvl1 sold as the new wallet.
I’m very sure without restarting the app the save and load also doesn’t work correctly with your code. I think the menu value is correct without restarting, because you fill the global variable.
Devinitively 1500 and 100 are not saved at the same time.
But idk, this part is missing on screenshot 1.
And the events in the menu scene should be subevents.

edit:

No, no. What you did is the Load and not the Save part :wink:

1 Like

Just change the order of the events
Depending on which events should be done first (In this case first add and then save).

1 Like

It’s really quite hard to tell what you are doing. You seem to have 2 global variables for score (Scorglobal and SoldScore) and a local variable Score. What do all the variables do? If they perform the same function, then reduce them to just one variable. It’s creating a messy situation otherwise.

Why are you writing the value of scene variable Score, but are reading to global variable Scorglobal.


You don’t appear to be updating scene variable score when you’ve written it. From what you’ve given us, I’d say the “Write to storage” event would be better written as :

(or change the value of SoldScore to Score)


And the “Read from storage” is getting called up every game frame. It Would be better written as :

3 Likes

clearly i have a lot to learn about gdevelop. i adapted your code and it works. thanks