SaveGame not working?

My SaveGame won’t work. I have my blueprint below. So I have a highscore variable, and if a player has a score greater than the highscore, the highscore gets set to that score. I have that blueprint running in user interface widget. So let’s say that the player had a last score of 100, and the player gets a score of 110. Then the HighScore will get set to 110. However, the highscore is still 0. I know for a fact that the score isn’t the problem because I used a print string and it outputted that the highscore is 0 and the score is 110. How would i fix this? Help is appreciated! Thanks!

Then is there anyway to get the score? The score is in the game mode.

Yes there is, cast to your gamemode set the object to get gamemode and " as gamemode " get the value of variable score or whatever it is named. Your blueprints are correct its just i guess u have done something wrong somewhere else or i guess u arent getting the values correctly try printing out the values before save i guess. Comment if u have problem if i can ill help

Not 100% sure, but it looks like you are saving the SubClass variable that you set, as opposed to the casted one you change the high score of?

When I save it, the save game object pin is connected to the sub class. What should I do from there?

So do you think the error is that I can’t cast to the game mode. Is that the only error you see. What other errors do you see?

Give me a summary on where u are saving these things from, What are the variables and where are the variables saved. ill send u a project link then with a working copy :).

They are set to editable

So I am saving these variables from a user interface widget blueprint. I am trying to set a high score variable float, that is located in the save game, to a score float variable from my game mode. In my game, when the player gets a high score, it sends them to a user interface widget called Highscore, where they can type in their name. Once they press enter, their name and the highscore gets saved.

single player

Is this single player or multiplayer?

This is working one. I tested it with PrintString.

Note that, first cast and promote to variable next. As you can see below, I casted to GameModeReal and promoted to variable ‘GameModeReal’

Next, I casted the save file (loaded from slot) and promoted to ‘SubClass’ variable. So, ‘SubClass’ is not a SaveGameObject directly. It’s a RealSaveGame class that is inherited subclass from SaveGame class.

And then, I compared if Score(GM) is bigger than HighScore(Save) or not. If Score(GM) is bigger, then set it to HighScore(Save) and Save the SubClass to slot as SaveGameObject.

Promoting to Variable isnt really needed but this works.

Ok I see how to do it now. Thank you so much! It works!

I did it for maybe he would use later. I didn’t know how he will use this because I didn’t work on single player games so far. I would use Save/Load in PlayerController or GameInstance.

So, I tried the code for a second time and now it doesn’t work. It was working before but, why isn’t it working now?

Don’t use cast in GameModeReal. When you CreateSaveGameObject, you already return it as SaveGameReal type. Delete unnecessary castings. The blueprint you show in video isn’t same as mine.
You are trying to print value from a newly created savefile which isn’t saved to slot, in GameModeReal. The BP I sent you is taking HighScore value from GameaMode itself, not from newely created save object’s score value.

Ok, Thank you for telling me this. I will try this later in the day.

Hello Ottoman. I have done what you have said to do and it doesn’t work still. I have decided to link my project right here, so you can actually download it and access my project. Please help my find this error together. Thank you so much for your help so far!

This is saving the last score I achieved to save slot if my last score is bigger than last saved highscore.