Click textbutton cooldown

I think this is a simple thing to do, but I forgot how to make a click cooldown. Can someone help me please?

1 Like
debounce = true
debouncetime = 1

     if debounce == true then
     debounce = false
     --your code
     debounce = true

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

	if buttonPressable == true then
		buttonPressable = false
		print("Button pressed")
		button.Text = "3"
		button.Text = "2"
		button.Text = "1"
		button.Text = "Next"
		buttonPressable = true
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.

1 Like

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.