[Resolved] Make a coin +1 to global variable in text

How do I…

Get a coin collision to add 1 to a global variable, showing up on the screen?

What is the expected result

When the player ‘bee’ collides with a ‘coin’ object, it should 1. delete the coin, 2. change global variable ‘coins’ to +1, and 3. change the text on the screen to "Coins " (coins)

What is the actual result

When the bee collides, the coin does delete, and for just a frame or two i can see the value changing to the correct number. but then it snaps back to “Coins 0” immediately.

Related screenshots

Project files (optional)

Insert a minimal game showing your issue in a .zip or .rar.

I can’t see a reason why this shouldn’t work… although, I don’t see anything that puts "Coins " in the text either, just looking at the screenshot here it should only show the number (unless you have a separate text object). Can you upload the project?

Correct expression would be change text SET TO

"Coins "+coins

Or 

"Coins "+ToString(coins)

I’ve got the text programmed with a prefix to say ‘Coins’.

How do I upload the project to here?

Put the project folder in a .zip file and then drag it into the reply box

1 Like

Actually I think I just fixed it! I had a rolling counter behavior attached to the text that was messing everything up. I removed that and added "Coins " to the event code instead and that fixed it :slight_smile: