Variable read/write problem

I have two scenes in my game: a scene named ‘Start’ and a scene named ‘Ingame’. In the Ingame scene there is a display that shows the amount of coins collected during one game. In the Start scene I want to display the total amount of coins collected over all games. For the Ingame scene I use these events to display the amount of coins collected (and of course besides these events I also use text events to display the variables into text):



In the last image you can also see the ‘write’ events. Here I change the global variable CoinCount by adding the amount of coins collected during that game. The global variable CoinCount is written in a storage.
Then in the scene ‘Start’ I want to display the global variable by reading from storage and storing into a scene variable like this:

But the problem is the display in the ‘Start’ scene initially displays 0, but then when I collect one coin in the ‘Ingame’ scene, this display goes to something like 715. I have no clue what’s the problem. I appreciate all help!

Hi try to add something like this in your Start scene


So you check if coins exist in Storage if not Write a record
In your Ingame just add the second event and check if “coins” exist assign to a scene variable then to assign that scene variable to the GlobalVariable.
Plus try adding Trigger Once when you increment the values on Coin Count, that way you ensure the Write GlobalVariable(CoinCount) only happens one time.

Extras: you need to check
– Your variables are set to number


– And the size, z-order, layer of the text you’re using to display the coins count.

2 Likes

Thank you so much! I will check out your solution soon. Thanks again!