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.
COMMUNITY QUESTION
How do I make a timer after clicking a part?
2 answers
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)
2 comments
0
this is not what he was asking for. Your awnser is invalid
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
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
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.