I’m already saving the coins to Firebase Realtime, and that part works fine. I have a global variable called MonedasTotales. While I’m in the game, the coins update live in the app and also update in real time on Firebase. The text in the menu that shows the coins also updates correctly as I collect more coins.
The problem is this:
When I close or restart the app, the coins don’t get loaded from Firebase. So when I come back, the “coins” text shows 0, and the MonedasTotales variable is also 0. Since that variable is now 0, when I collect coins again, it saves that new value and overwrites what was already in Firebase, so I lose the previous amount (for example, if I had 7 coins in Firebase, it gets erased and replaced with the new value).
Hello and welcome. In your beginning scene event, you are getting the player coin value MonedasTotales from Firebase and storing it into a variable called temp. Then you overwrite the variable temp with the value of the game variable MonedasTotales, which is probably 0 since the game just started. Try instead to overwrite the value of the game variable MonedasTotales with the variable temp that you had just stored the value of MonedasTotales from Firebase into.