i get this error Blueprint Runtime Error: "Accessed None trying to read property Main HudRef". Node: Update Ammo Text Graph: Shoot Function Function: Shoot Function Blueprint: BP_FirstPersonCharacter

i am making a first person shooter and i want to see my ammo go down int the botttem right of the screen but the way i have made it i get this error Blueprint Runtime Error: “Accessed None trying to read property Main HudRef”. Node: Update Ammo Text Graph: Shoot Function Function: Shoot Function Blueprint: BP_FirstPersonCharacter i need help to solve this isue this is my first person character blueprint


this my shoot function



this is my main hud widget

After you create the widget, you need to store it in the MainHudRef Variable.
eg:

Here I’m using one called Main overlay, but is the same in your case, just replace with with MainHudRef

Is kinda hard to see with the small images, but it seems you’re creating a new main hud every time you shoot?
Just access the variable, the hud should already be created just one time at the start.

thank you for the answer i still have a question though how would i access the variable in here instead of creating a new Main hud

Just drop in the “get” node from the variable where you stored the widget in.
From there you can call anything on the widget class.
eg:

I’d recommend you follow through this learning resource: Blueprint Communication | Course

it goes over all the ways in which you can send info between blueprints.