Use the same variable in 2 blueprints

Create the CoinsCollected variable in Player Controller, Game Instance or Game Mode BP. Those are some of the BP’s that you can easily access from any other BP(i.e. Get Player Controller > Cast to yourplayercontroller > Get/Set CoinsCollected) Then you can get and set the variable in your coin BP and then get it in your GUI BP to display.

I have a blueprint called Coins which holds the variable I want to use -

I want to access this variable in a blueprint called Coins_GUI. This is my current method -

When I run the script I get the following error -

Thanks in advance to anyone who can help me

I have tried every possible combination of that and I still can’t get it to work

I am working from the rolling template. I added the Coins Collected variable to the RollingGameMode.
I then tried to do a get coins collected but I can’t seem to get it.

Tried this but the script doesn’t appear to execute -
EDIT - Wrong image

How exactly have you tried it? Can you post screenshots please? I have been doing the same thing by using GameInstanceBP and it works perfectly.

It doesnt because you arent firing the Cast node in the screenshot, and you also need to Get that variable so that you add 1 on top of it with every overlap event and then set it with the result. Like so:

I’m using the player controller here but you can use the Game State(correction to my earlier post: use Game State instead of Game Mode) If you use Game Instance the information is saved between levels so consider that as well.

Have you tried using a variable of the class instead? And experimenting around with that? Also I got a good laugh out of the string in the print node on cast failed

Can you post a screenshot of the blueprint where you call/display the HUD?

Right. I have a PlayerController (GameMaster) and when I try to execute a cast to, it fails -

I made some adjustments to the gamemode and now it will let me set the variable in GameMaster and the blueprints can access it but for some reason my GUI isn’t updating -
Glad you enjoyed the cast failed :smiley:

Try creating a custom event that fires after the coin is picked up, and make the event tie into the show hud blueprint (like where you are firing every time you start game) make it remove the HUD and re-add the HUD to the viewport. It should work but it might be pretty hefty in performace, I’m not sure