Loading from main menu is not working

So i have a Main Menu Level and no matter what i try , i can’t get the load to work. It only loads the correct level but not the other data like coins collected and health. Inside the Main Menu casting to third person always fails. So what do i have to do in order to get it to work? Thank you in advance!!
So these are my loading blueprints.
First is the blueprint in the Main Menu.

Here is the custom event LoadMyData in the ThirdPerson blueprint

And this is the LoadData function in the Game Instance blueprint

MajinSephiroth this is how i save my data. I believe the values are correct since it loads the correct level. This is the custom event SaveMyData inside the third person blueprint.

This is the function SaveData inside my game instance blueprint.

Finally , this is my in-game-menu and here i call the custom event SaveMyData from the third person blueprint which calls the function Save Data from the game instance blueprint .

Where are you saving your data?

When you save data, are your values correct?

Well your first observation has a point but it shouldn’t actually be the problem, i believe.

Well they aren’t different because if they were, not even the correct level would load but since it loads the correct level , isn’t that correct?

Why do you create a new save game every time instead of loading saved if it exists and saving that one?

The only thing I can think of is your save file names are different from the load file names. Based off of what I’m seeing in your setup anyway.

That is correct, the first point shouldn’t be the cause of your problem, it was just an observation.

My recommendation is to step through your save functionality and make sure the values exist prior to saving.

Another thing I’d be interested in would be to load your save game after you created the save and check the values at that point and see if they are as expected.

There is a break in communication somewhere in your blueprint, hard to pinpoint without more testing.

Ok , so i placed some print strings and i found that the values are ok before and after loading , the problem is that at LoadMyData in the third person blueprint the values are actually never set. The print string in the red circle is doesn’t print anything (neither does the one after the set health) so the blueprint doesn’t reach that far. Any idea why?

ok , so after some more thinking i realised that on load in main menu i am calling the LoadData function which is in the game instance blueprint and not the custom event LoadMyData which is in the third person blueprint, but when i try to cast to third person in the main menu it always fails. So if i call the custom event LoadMyData from the third person blueprint in the main menu it should work. Do you know how to do that since cast to third person always fails in the main menu?

LoadMyData is part of the third person blueprint which is basically another level that is not empty.

Yes i exit the game and then try to load from the main menu level which doesn’t have the character. Do you know how i can find a way around this?

Is LoadMyData part of the in game menu or a separate start up menu that is basically an empty level?

I mean if you exit your game and try and “load” a saved game I assume you wouldn’t be loading from an “in game menu” since you haven’t technically started the game yet. So the only reason to fail the cast to third person means you don’t have the character in the level.

I wouldn’t have load or save game functionality really in a character BP. Like it’s ok for them to call functions to load and save the game but the functions themselves should be contained within more persistent blueprints like the game instance. So my suggestion is to move the function that loads game data from the player to the game instance. This way your main menu load button or “save” whatever you called it that actually tries to load a game, that button will call the load function from the game instance which you can easily cast to because the game instance is always present when you play the game no matter what level or menu you’re in.

You can’t call that function until you have loaded the level that contains the player. So when you load your game all you should be doing is opening a level. Level 1 for example. Then on begin play of level 1, have it call the load function from the game instance. Then your character will be present and it won’t fail.

Ok so i moved the custom event LoadMyData from the third person to the game instance blueprint but when i do this i still have to cast to third person to set health and the other data but the cast fails. So it doesn’t work

It finally works!! Thank you very much!!! :smiley: