I think this is a simple thing to do, but I forgot how to make a click cooldown. Can someone help me please?
debounce = true debouncetime = 1 script.Parent.MouseButton1Down:connect(function() if debounce == true then debounce = false --your code wait(debouncetime) debounce = true end end)
Does it work for local scripts?
Yes it does. A debounce doesn’t differ depending on whether it’s on the client/server as it’s just a boolean variable.
It’s not working using a local script, though
A few things:
- Show a picture of your explorer with the LocalScript visible
- Send the script you’re using here (with the changes you’ve made to adapt it to your game as the script that was supplied to you above isn’t universal)
Yes is work on localScript but if you use RemoteEvent after Exploiter can bypass the cooldown
I know this isn’t the best way to do it but it is super simple and you can see how much time is left:
local button = script.Parent.TextButton local buttonPressable = true button.MouseButton1Click:Connect(function() if buttonPressable == true then buttonPressable = false print("Button pressed") button.Text = "3" wait(1) button.Text = "2" wait(1) button.Text = "1" wait(1) button.Text = "Next" buttonPressable = true end end) And you could also tween a frame from left to right or the other way around to show you how much time is left.
why do debounce on the client when you can do it on the server
He has to do debounce on the client because he is using a MouseButton1Click/ MouseButton1Down event
The LocalScript looks like it’s in StarterCharacterScripts, and MouseButton1Click is only an event of GuiButtons. The only reason your code doesn’t work is because you didn’t put the script in a GuiButton. Put it in one and see what happens.
Yeah i saw that and i was about to say that.
Also, your using
script.Parent.MouseButton1Down which won’t work as the script.parent is the StarterCharacterScripts and not a TextButton.