I have a game where you earn points while you are playing and in the end of the game it checks if your game point value is bigger than the high score and if it is it replaces the value. When i try to print the value it always prints 0.
Unless you are performing operations on your SaveGame object somewhere else, this will always return 0.
Essentially you are loading (or creating) a save game object, then you are comparing the “saved” Score Coin to the “saved” Best Score.
When you create your object, it initialized the variables to their defaults, so you are essentially setting them to 0 and nothing else (assuming of course you are not modifying the save object somewhere else.
Your Score Coin should be set at the end of a game (or whenever you need it to be) before this operation happens.
If you don’t have a savegame (and therefore no score) you still check if the score is larger than the old one even though the old one is null or the default value because you just created it.
Also you are checking the ScoreCoin value against the BestScore variable. Now that can work but you do have to save the game to the slot every time you modify this variable and in general I’d suggest just using a normal variable to check against since the current score doesn’t really need to be saved. In anyway if you want to modify that or not (there can be good reasons not to! This is just me speaking having no idea of what this is supposed to do!) you should really check your scorecoin variable if it contains anything and is saved properly.
The ScoreCoin is being set before. The picture i sent shows what happens when the game ends. it takes the score coin which is the value i gathered from the game and than compares it with the highest score, which is in this case zero. The score coin is of course more than zero but when i print the highest score value after it was “changed” its still zero.