Need help with Load/Save Function

So I created a main menu and pause menu. Set up a Save Game button in the pause menu, and a New Game, and Load game button in the Main menu. The save slot variable is on the Main Menu, and I created a Reference to the Main Menu widget on the Pause Menu widget, however I keep getting this error when I try to save in the game test window:

“Error Blueprint Runtime Error: Accessed None trying to read property MainMenu Reference from function: ‘ExecuteUbergraph_PauseMenu_Widget’ from node: Does Save Game Exist in graph: EventGraph in object: PauseMenu_Widget with description: Accessed None trying to read property MainMenu Reference”

As far as I can tell, it is stopping right at the beginning of this code:


(This code is on the Pause menu connected to a button)

I think it’s just not pulling the info from the Main Menu widget? but just in case, I’m going to show everything:

(Pause menu) Variables and Functions:
Pause Menu Variables and Functions.png

(Pause Menu) save Function:

(Main Menu) Variables and Functions:
Main Menu Variables and Functions.png

(Main Menu) Load Game Button:

(Main Menu) Loaded Game Function:

(Main Menu) Load Saved and Set Variables Function:

Anyone know how I might fix this?

It said: “Accessed None trying to read property MainMenu Reference”
That means that your mainMenuReference variable is empty. Can you show us where you set that?

Im not really sure how to set it. i got that same question on reddit, but unless im mistaken, i dont think i had to set mainchar1 or savemechanic to get a reference to them. i couldnt find anything online today about how to set it (granted i didnt have much time to look while at work today). im going to try a suggestion from reddit to create a game instance and set up the save and load functions in there, and reference thr gameinstance to the menus. but can you explain what setting it means? sorry for being a noob, i just started learning ue4 last weekend.

Okay I figured out how to set stuff, and I got most of the code working. It was originally breaking because the MainMenu reference wasn’t set, so I set it all up again in a new blueprint called GameInstance blueprint. Now most of the code is working. I got the save function working properly, and the load function seems to be working, but the problem is now on the SavedAndSetVariables function. I set mainchar1 and the SaveMechanic and put it back together, however it wasnt working. I set up a whole bunch of print strings to find the problem, and it is that I didnt set mainchar1 right? I guess? I cant figure out how I’m supposed to set it properly. If i just set the reference (without casting to mainchar1) it will go through the whole code just fine, but return the error after the fact that it couldn’t read mainchar1, so it seems my only problem is casting to mainchar1.

Heres a pic of the code:

I’ve tried it without the set mainchar1, tried it without casting (which works but cant read mainchar1), tried flipping the order, etcetc. Idk how i’m supposed to set this.