Saves not working (casting)

Hello, I was trying to make a high score system on my game. However, even though mostly everything works fine, the one cast that I need to work fails. Here’s what I did:

  • Created a save game blueprint, with a float named “High Score”
  • Compared the normal score with the High Score variable, and if it is greater than or equal to it, then to cast it to the save game blueprint in order to replace it with the new variable.

Here’s what my pawn blueprint looks like (where all this is going on):

I really appreciate your help! Thank you.

From messing around with it, I know that the problem lies somewhere with the object (Save Game Object), I just don’t know what it is.

you should make saveGameObject into a reference to your custom save object type, then cast to it after load or create, rather than casting every time you want to use it.

Hi, thanks for your reply. By that, do you mean to change the variable type from “Save Game” to my custom save blueprint? Or am I getting this wrong?

Sorry, I’m a bit new to this, so I get confused easily XD

the type your variable “SaveGameObject” should be a SaveGameScoreBP instead of a SaveGame.

Yeah, that’s how I did it at first. But when I did that, everything got messed up, and I remember watching a tutorial where they had the same setup that I did. I’m going to do what you said / how I had it originally and see what happens.

This is what happens:

after the createSaveGameObject node, cast it to your custom type before setting.

Thanks for your reply, unfortunately, the cast still doesn’t occur. Here’s my current setup:

Made a few changes, I thought it could work, but when I try running the game it pops up with an error that says “Error Accessed None ‘SavedGameBPReference’ from node Construction Script in blueprint TriangleCharacter”

Alright, I re-did everything. The cast highlighted doesn’t pass, any ideas why? :L

as long as savedGameScoreBP is a type of SaveGame object, the only reason i could imagine that cast would fail is if your old save file was created using a different type of save game object, before you changed your variable type to your custom save game object.

try deleting your save file, then run your code. it should create a new save file of the correct type, and then it should work.

here is what worked for me:
https://answers.unrealengine.com/questions/25747/how-can-i-savegame.html

Thanks again, you have no idea how much I appreciate your help :slight_smile:

sigh unfortunately, I deleted the file, and the same thing happens :frowning:

HOLD UP, I think something happened. (something good) what you suggested worked, I think. Give me a bit to test things out :stuck_out_tongue:

That worked!! Thank you so much…

I just came in here for the answer, and as i expected, ill need some kind of magic or a miracle to get this working for today