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

Is it possible to make a clickdetector cooldown?

I have tried making a click detector cooldown but what it does is just remove the clickdetector then after a few seconds it breaks the script.

1 answer

You could add a debounce to the script.

local part = game.Workspace.Part
local clickDetector = part.ClickDetector
local canClick = true
local clickTime = 5 --Time in seconds

local function onMouseClick(player)
	if canClick then
		part.BrickColor = BrickColor.Random()
		canClick = false
		wait(clickTime)
		canClick = true
	end
end
 
clickDetector.MouseClick:Connect(onMouseClick)

6 comments

0

It’s BrickColor.Random(), not random(). And it’s Connect, not connect. Please stop giving users old, broken deprecated code.

0

Ive always used "connect" I've never had any problems ???

0

It lags and delays.

0

I just took it from the wiki

0

eat a dick

0

Mind you language BaconOofIsBest

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