How to limit a button function so even if the player is spamming the button, the function just works once?

Hi guys

I’m having trouble about button functions being called multiple times.

Whenever the player spams a button, like in quiz games which they have a submit button or something.

Ex.

Fills up answer -> then spams the “Submit Button” which calls the function multiple times which results to an error.

How can i limit the button function so that even when spamming the button, the function just works once for every correct question.

The easiest way I have used is to add a flag

When processing a button press check to see if the flag is set.

If it is clear, set it and then continue on with whatever the button should trigger.

On each press the flag can be checked, if it has been set already then the button has been pressed and you can drop out without doing anything further.

Clear the flag at the end of the ‘round’ and allow the button to be pressed again.

Jules.

The easiest way I have used is to add a flag

When processing a button press check to see if the flag is set.

If it is clear, set it and then continue on with whatever the button should trigger.

On each press the flag can be checked, if it has been set already then the button has been pressed and you can drop out without doing anything further.

Clear the flag at the end of the ‘round’ and allow the button to be pressed again.

Jules.