[SOLVED]Score Display Error

Here is the object variable and the code. When the scene starts, the score does not display; why is this?
Please let me know if I should include more information to reach a conclusion.

Try setting to zero the variable value at begin of scene.

Hmm, my set up is a bit different so I don’t know how much help it will be.

Coins and score points are displayed separately in my game, but I do award points for collecting coins in addition to other things. You don’t need to set the variable value to zero at the beginning of the scene, since it’s already zero by default.

I found it much easier to use a Global Variable for the Score, instead of an object variable, especially if you want the score to continue increasing when the scene changes.

In your case, I would probably do something like…

updog is in collision with coin
Do +1 to global variable Score

On a separate line, no condition needed, update the text:
Do ="Score: " + ToString(GlobalVariable(Score)) to the text of Score

When I first added scores to my game, I made it so complicated with the object variables. But using the global variable turned out to be very simple. Sometimes less is more :wink:

1 Like

It seems to be displaying “Score: 0”. This is the code:

i made the global variable “scoreAmount” as well :confused:

Darn. :frowning: I’m not sure why the amount isn’t increasing for you, sorry.

May I ask, what is coin2 for? If it’s to increase the amount, it isn’t needed because the event should just do +1 when you collide with each instance of the coin object on the scene. I don’t think that’s a solution to your problem though. :\

1 Like

coin2 is the second coin that appears on screen, separate from coin
Thanks for your help, though :slight_smile:

1 Like

nevermind, it worked! i had two “collision” events with the player. thank you! @jumpingj @Phenomena

1 Like