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

How do I make a timer after clicking a part?

Asked by 4 years ago

I'm trying to figure out how to make a timer after clicking a part so people don't get too much stats on the leaderboard.

0
Using a click detector you can fire a RemoteEvent to create a GUI (which is the timer). I will awnser your question in a bit, but just beware that the solution to your porblem is using a click detector to call a function when the brick is hit. RBLXNogin 187 — 4y

2 answers

Log in to vote
0
Answered by
Fako16 13
4 years ago
Edited 4 years ago

In the function that fires once the part is hit, just use the wait function, i.e

local clickdetector = ...  --your click detector
local part = ... -- your part

clickdetector.MouseClick:Connect(function()
    -- do what you want with your part here

    wait(x) -- x should be how long the timer will be, to explain it further, if you set it 2, the function wont fire again until 2 seconds pass
end)
0
this is not what he was asking for. Your awnser is invalid RBLXNogin 187 — 4y
0
pretty sure it was, read the whole thing, after clicking a part so people don't get too much stats on the leaderboard, pretty sure its what i described? if its not what is it Fako16 13 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Use a debounce with the ClickDetector's MouseClick event.

local clickDetector = script.Parent
local debounce = true

local debounceTime = 2.5 --Replace with whatever number you want

clickDetector.MouseClick:Connect(function()
    if debounce == true then
        debounce = false

        delay(debounceTime, function()
            debounce = true
        end)

        --stuff
    end
end)

Answer this question