Saving character stats **** up the save file

Hello, so I don’t get this system

I have a level menu. On this level in the MainMenu widget I set language and character stats, choose character mesh, create savegame object, save to slot. Everything is stored inside MySaveGame class
Then I start a game level, on begin play in character blueprint is loading all the stats I entered in the main menu from the slot
Everything works fine. I get correct language, correct character mesh

Now, when I try to save something from not mainmenu widget blueprint, for example -money count from the character blueprint - I obviously recreate a save game function from the mainmenu widget, create new savegame object, save to the save slot, to the same mysavegame class. Obviosly I have moneycount variable in the mysavegame class as well…
It messes up the save file! Save function executes, corrupts the save file - I see it on the game level blueprint, I have widgets that indicate nonexistence of a save file and later I exit game or go to main menu level, and there is no save game.

What the f! What to do! Please help…

Please guys, any help, please. I need to fix this

You shouldn’t hide things on your screenshots or just make sure there is nothing you don’t want us to see when printing to screen. It’s hiding main information such as the name of your SaveGame. I can’t know if you are recreating twice the same SaveGame.

To me it looks like you are creating twice a SaveGame at the same slot, which means the second you are creating is deleting the first one.

I’m not seeing the node “DoesSaveGameExist” in your logic and you should always make sure a SaveGame exists before trying to recreate one.

So it looks simple: on EventBeginPlay check DoesSaveGameExist, if it doesn’t create it. If it does, load it.

The second time you want to create it, do the same thing.

[quote=“Yun-Kun, post:3, topic:108868”]

You shouldn’t hide things on your screenshots or just make sure there is nothing you don’t want us to see when printing to screen. It’s hiding main information such as the name of your SaveGame. I can’t know if you are recreating twice the same SaveGame.

To me it looks like you are creating twice a SaveGame at the same slot, which means the second you are creating is deleting the first one.

I’m not seeing the node “DoesSaveGameExist” in your logic and you should always make sure a SaveGame exists before trying to recreate one.

So it looks simple: on EventBeginPlay check DoesSaveGameExist, if it doesn’t create it. If it does, load it.

The second time you want to create it, do the same thing.

Hello, thank you for your reply. I will post a screenshot without hiding.

My logic is initially different
I always have a save game.
First, If no save game exists, i.e it’s a first launch, game shows a language selection screen and save game gets created
After that, whenever save game gets deleted by player, the languages that is currently stored in ram creates a new save file with that language

The 'Savega" function you have is creating a SaveGame and only storing the MoneyAmount in there before saving.

This means if you previously had a SaveGame of the same name with other information than MoneyAmount, they are deleted at that moment. Is that what you want?

Mmm, not really, thanks for your hint. I was thinking that I can have multiple save game objects that store all kinds of different data within 1 MySaveGame class, like, 1 for moneycount, another for everything else, so that I don’t have to retype it or cast to other classes for some stats in order to set them and save them. Thanks a lot for clarifying how it works. Do I have to recreate all data inputs in the “Savega” function? Thanks!

You can definitely do what you’re saying. You just need to replace the logic which creates the new savegame in your ‘Savega’ function by a logic which loads it. You already done that in your event begin play. I suggest you look at some tutorials regarding save/load game because you are very close to doing what you want, you just got a bit of a logic trouble.

Oh, thanks very much man! Ue has indeed a great community