Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to make a Click Detector cooldown?

here is the code

local part = script.Parent local debounce = false

part.ClickDetector.MouseClick:Connect(function() part.Sign.SurfaceGui.TextLabel.Text = math.random(1, 8) debounce = true wait(6) debounce = false

end)

2 comments

0

oops

0

im sorry that i forgot to press enter when i put debounce _ false

2 answers

✓ Accepted answer

Yes. You're on the right track, you're just not utilizing the debounce correctly.

local part = script.Parent 
local debounce = false

part.ClickDetector.MouseClick:Connect(function() 
	if not debounce then -- This is the check we need.
		-- This will check if "debounce" is equal to false; when it is false, run this code, and we change it to true so that it won't activate while on cooldown.
		part.Sign.SurfaceGui.TextLabel.Text = math.random(1, 8) 
		debounce = true 
		wait(6) 
		debounce = false
	end
end)

1 comment

1

Thanks for helping me!

Maybe something like this(Not sure):

CoolDown = false

function Example()

CoolDown = true

part.Sign.SurfaceGui.TextLabel.Text = math.random(1, 8) 

Wait(3)

CoolDown = false

end

function Clicked()

if CoolDown == false then

	Example()

end

end

This discussion is preserved as it was. New answers, comments, and votes are closed.