Why won't this debounce script work?

Hello.
this script is a child to a button, however, I cannot figure out why the debounce script is not working. It does not stop the player from spam clicking the button…
I cannot figure out why.
Everything is referenced correctly.
No errors.

Help please XD.

Because every time they click the mouse button you are just setting debounce to false again in the first line of the function. To fix this, move

local debouce = false

outside of the function

2 Likes

I believe you should move the first

local debounce = false

to before the first line (the function) because every time you click the button and call the function you are making debounce false.
Haha, @supergreatr299 beat me to it.

1 Like

Ok, 2 errors,

  1. As the others said, move the local debounce = false out of the function
  2. This is a local script I assume, so why are you trying to use FireClient()? Just do it in the script itself.
1 Like

yes haha just found that fire client error.
Thank you for spotting it though.

Also do you not want to set debounce to false after the 10 seconds wait?

yea sorry, I saw that. Changed the true to false at the end :slight_smile: