Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to make a clickdetector cooldown?

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
It’s BrickColor.Random(), not random(). And it’s Connect, not connect. Please stop giving users old, broken deprecated code. User#19524 175 — 6y
0
Ive always used "connect" I've never had any problems ??? superender11 -17 — 6y
0
It lags and delays. User#19524 175 — 6y
0
I just took it from the wiki Creeperman1524 120 — 6y
View all comments (2 more)
0
eat a dick BaconOofsIsBest -13 — 6y
0
Mind you language BaconOofIsBest KawaiiX_Jimin 54 — 6y
Ad

Answer this question