Accessed None error when trying to access variable from a widget blueprint in regular blueprint

As that title says, I am trying to access some Boolean variables stored in my widget blueprint, from my game mode blueprint and vice versa. I have tried countless methods and nothing seems to work after hours and hours researching on the internet, and I cant seem to be able to reference any kind of blueprint from another blueprint.

Can you provide a screenshot of the error? Also please show what’s in GetUINewGame and GetDifficulty.

I’m not sure what GetUINewGame is supposed to do. You have a variable for UINewGame, a function to get UINewGame that you need a reference to UINewGame to call, and a second variable also for UINewGame.
After requiring that this unrelated piece of code works, you then call a GetDifficulty function within yourself, promoting the result of that to a variable that is also contained within yourself.

Sorry for the late reply, these are the boolean variables that are stored inside UINewGame

and this is the part inside the UINewGame widget BP

This is the errror

I meant could you show me the inside of the two functions- particularly GetUINewGame.

According to the error, UINEWGAME (all caps) isn’t valid.


There aren’t any issues with communication, this just means that you haven’t set UINEWGAME to be anything.

ah okay! So I have actually made a few changes and not using that function but instead using a create widget to call that UI so I can access the variable there, but they don’t seem to be working. I have attached the get UI New Game function though.

but even if I use a create widget like this

it doesnt throw any errors up but then trying to use the booleans from the UI New Game BP in the GM blueprint all come back as false even though depends on what button is clicked will turn one of them to true, but doesnt seem the case

I’m having hard time reading this.

The booleans will return all false because when you create widget you leave them all false (Create Widget Node).

You should definitely delete the function if you aren’t using it. Also the function itself wouldn’t to anything. All it does is cast self into a UI_NewGame, but to call this function the variable would already have to be of type UI_NewGame.

You also should just use the enum you already have for difficulty. Get rid of all the bools.
image

You can remove the nested if statements with a select node:


Also as is you’re only creating 3 enemies no matter the difficulty- you need to plug the villager count into the for loop last index.

1 Like

Hmmm I see, I wasnt sure how to use the enum to state which difficulty is selected in the UI_NewGame, how would I be able to do that?
and yes I was trying to figure out how to set the villager numbers but couldnt test if it worked due to the booleans always returning false haha

This being how the buttons are set to set the difficulty

then set it up like you shown above, but its crashes after choose the difficulty and starting the game

could be the difficulty functions, I have 2, 1 is each BP because again I cant communicate between blueprints, but they both store and read from the same enum so this should be an issue i think

Are you trying to access a widget on client from GameMode ?

To my knowledge (which is not alot ) , GameMode only exists on server and widgets only exist on each clients and not on server . maybe this is why you cant access variables on a widget from your GameMode .

yes that is what I am trying to do, my knowledge is not a lot either but if they do in fact work on server or client, they should have someway to communicate … some how