This is my shop button when pressed takes 10 coins from player. It works perfectly fine if game is restarted.
So lets say you collect 10 coins restart the game then you will have 10 coins and all other variables will be saved aswell. But if a player collects 10 coins and doesnt restart the game then the player will still have 10 coins but when pressed the buy button all other variables will be reset to last restart of game.
Also if button is not pressed then other variables arent affected and do not change. Any help will be appreciated.
you know you are deducting twice in a row, any reason for that?
Hey @Tsiqz!
The answer to this is going to lie somewhere else, unfortunately. All the other variables you’re talking about need to be included in your “GameData” GameInstance in some way before saving your data to slot.
I would recommend not putting that “SaveDataToSlot” here, but somewhere using a button etc, that would grab all values of variables that need to be saved, add them to your “GameData” object, and THEN save to slot- which you don’t want to do everywhere anything changes.
@KryogenicGames They’re deducting from the gameInstance variable and from the GameData, so removing from short term game and long-term save, it’s two separate variables.
That actually brings up another point: Better to take out that “Subtract from GameData” group of nodes, and when saving just use the current value as the new savable integer instead.
Thank you @Mind-Brain for replying
Im still a beginner trying to understand how the blueprints work. i know it probably isnt the ideal way to setup that blueprint but your saying this isnt the main root of the problem. as your more advanced is there any way you could know where the problem could be like something with the game instance or something?
In this saveslot is just a string of my savegame which is called saveaudio
Well, you have your answer right here! The only variable you’re setting is “GameCurrency”. You say every other variable is reset. Any variables you want to keep should be saved in that Save Game Object before saving to slot. Everything not set in the SaveGameObject used when saving will reset to initialization. But ALSO:
When you’re doing your load from game slot, you’re only setting game currency.
You have to do what you’re doing here for GameCurrency for every variable that you’re bringing from the saved game.
If you’re new to blueprints, I highly suggest going through an in-depth tutorial to learn all the ins and outs. Saving is a complicated beast!
Thank you very much
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.