Engineering Coin System

Hey guys, first post here - I have been following several tutorials for adding coin collection + a visual counter of them on screen - the tutorials I have followed have been completed succesfully as far as I can see but it isn’t working so I am seeking the knowledge of the professionals here to help me complete this. Detailed help + pictures appreciated.

So far I have a coin blueprint in my game, when the actor walks over it, it disappears and plays a sound. That is all working. What is not working is a visual counter of it on screen. Here is what I have so far.

Level Blueprint

ThirdPersonCharacter Blueprint

ThirdPersonCharacter AddScores Function

Coin Blueprint

I have also created a new widget and named it HUD and have added a text box to the screen where I want the counter to display. (I think I need to bind the textbox to something but not sure)
Right now I believe the blueprint is trying to print to screen and not print to the HUD
Also after collecting a coin in game then quitting I get a message in my log that says "Accessed None ‘Player’ from node Add Scored in graph ‘EventGraph’ in blueprint Coin

Thanks in advance guys!

Ok so there is a lot of stuff in those blueprints that are doing nothing.

The first 2 images do absolutely nothing at all so just delete those.

Also on your event “actorBeginOverlap” you will want to make sure the other actor is the player.

But the main error here is that you are destroying the actor before the “Add Scores” function is called which means it doesn’t even exist to call that function. Destroy the actor after add scores is called, preferably with a small delay node in between like 0.1 second or so just to make sure.

OK so I have deleted the first 2.
On my Event “actorBeginOverlap” when I drag off other actor and search for Player nothing pops up, the only thing available is Cast to ThirdPerson, when I drag the Player variable onto the graph it doesn’t allow me to connect it that way either.
I have moved the Add Scores in front of it being destroyed, but after compiling it, and playing the game the coin still disappears, plays the sound, then destroys - but no visual counter of it on screen can be seen still.

Here is the Coin Blueprint after your suggestions.

Also I might should mention that this is what happens when my game initially loads.

What’s happening here is that when the game loads, my background game music starts then the HUD I have created loads. This is working perfectly I am telling you this so you know that I have a HUD already created and loading at the beginning of the game and that on this HUD I have a textblock on it. I am trying to get this textblock to display the number of coins collected when the player walks over it in game, when that happens the counter goes up.

Thanks in advance.


Any help from the experts here?

Here’s a way to make sure it’s the player overlapping.


I think everything else looked fine in the Add Scores function.

As for your HUD, you should be able to cast to your Third Person Character blueprint and get the Score variable and bind that to your text in the widget. Yell if any of that doesn’t make sense.

ok after looking at your image this is my new coin blueprint

I dropped a text block on to my HUD and next to TEXT I clicked on bind and this is what it looks like.

After saving and compiling I played my game, everything is working as it should except the textblock is still not displaying or calculating the collected coins - I am also getting this error message every time I pick up a coin in the message log.

Please help me get this working, many thanks in advance.

In your third picture of the widget text bind, you are not using the right Scores variable I think. You cast to your third person character, but don’t use it. You need to drag from the little blue dot on ‘Cast to ThirdPersonCharacter’ node and type ‘Get Scores’. Then connect that Scores variable to the ‘ToText(int)’ node and see if that works.

Each widget/blueprint can have its own variable with the same name and they don’t share values. You need to decide where you are going to store the ‘master’ score and always grab from there. In your case, it’s in the ThirdPersonCharacter blueprint.

Thanks for such a quick reply Gooner!
I have changed my blueprint to match what I think you told me. Notice the compile errors underneath when I compile that, any fix for those in the message log? Also The coins are still not calculating on screen.


Could these warnings and errors I am getting in my message log when compiling or collecting a coin be the reason it isn’t working?

It seems I got rid of the compile errors in the HUD - the only error left now when compiling is “The execution path doesn’t end with a return node” but I have a return node at the end it looks like so not sure how to correct this.

That’s just a warning. I’m not sure that affects anything, but if you want you can put a print string with a message to remind you what failed and then add another return not after that so it stops whining at you.

Does the UI display your score now?

do that cast inside your event graph, plug the event construct to cast and then promote that to a variable, inside your function get the variable you created.

The textblock on the UI still doesn’t show the score. Because it says CAST FAILED at the end of the warning I thought maybe this is keeping it from displaying, but if the warning isn’t affecting anything I will just leave it for now.

“do that cast inside your event graph, plug the event construct to cast and then promote that to a variable, inside your function get the variable you created.”
Can you be a little more specific here? I am new to UE4 and just started classes, still learning most of this, and I really appreciate your help, are you saying to copy and paste what I have currently in GetText_0 to my event graph? And keep the other one there as well?

EDIT: take a look on this answer:

i posted a screenshot about how to pass a value from player to widget. its not a score but the process is the same, take a look and if you have more questions feel free to ask. I would just advice you to study a bit of blueprints communication, casting, events dispatchers =)

I changed the event graph, this is how it looks now. Is this what you mean?

Then compile/saved it - started game, ran over coin, and still no calculation on screen in the textblock.

Also still receiving this error message in the log after I run over a coin, could this be the problem?

Here is another suspect for the problem perhaps.
I notice in my AddScores function in my ThirdPersonCharacter BP that it’s ending with a Print String, I think this is wrong, from what I understand Print String is only for debugging purposes, I am wanting the scores to display on a textblock in my HUD, should the Print String here be changed to something else, or something added to it maybe?


you are doing it wrong.

1- when you cast, get that blue plug: promote to a variable (give the name you want)
2- inside you function get text 0: get this variable > get score > plug to return
3- delete the things after your set scores: inside your add score function

ok after doing what you said, the textblock on the UI still doesn’t calculate. I may have done something wrong trying to follow your list.

As for #1 I think you are talking about the cast inside the HUD Event Graph, I pulled off from As ThirdPersonCharacter, clicked on promote to variable, named it ScoreVar (not sure a good name for this), and then from there connected that back to the scores var.

As for #2 I pretty much did the same thing, dragging off the same and then typing ScoreVar then connecting that back to scores.


#3 I deleted everything past Set Scores.


You are still confuse about the cast thing, i made some prints with exactly the thing you need to do. Please take a look:


Still is not working and I believe I have done everything correct.




Also I am including a look at the COIN BluePrint - this is the item that is supposed to add to the textblock score when destroyed. Notice below the Rupee Collection section, there is more Print String, not sure if that should be there since I am wanting to send that info to a textblock and not the Print String debug way.

Also still getting this error in my message log when I run over a coin in game.

Inside your coin bp: that south part of code (out of comment) is doing nothing, you can delete that.
The problem is in your coin blueprint, use the follow screenshot to fix it, and it will work, you can put the cast after your play sound for example.
With that cast your coin blueprint will be able to have access to functions and variables of your player blueprint, so now you will be communicating them.