I have a problem with the scoring

I am creating a game of questions and answers and every time I choose an option it adds 1 point, the problem is that every time I click on the option it does not add one, it adds many more, how do I fix it?

Add Trigger Once in the click Event

1 Like

I think that @UlisesFreitas solution will do the trick.

However, on a more general note, what you need to understand is that the code you write is executed from start to bottom every time a new frame pops in. So, if you are running on 60 fps, your code will execute 60 times per second. As such, this “issue” that you stumbled upon, it will come up again and again.

Not an experienced user of GD, but I think I’ve understood this correctly.

In the more difficult cases, where there are multiple conditions and actions in an event, what I do to overcome this is introduce logical variables to “break” an event affected by this rule into two events or stop consecutive executions of the same event.

In your case, even with trigger once, if the answer remains visible, if you click 5 times on it, it will add 5 “triggered once” points. In such a case, you can introduce a logical scene or object variable “answered” with starting value 0 or string “not” (if you don’t like the “geeky” not) and say:

answer is clicked
variable answered is 0

add one point
change variable answered to 1

This way, when the next frame pops in, it finds the value of variable answered as 1, and essentially neutralizes the effect of clicking again and again the answer on your players score.