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.
In the function that fires once the part is hit, just use the wait function, i.e
1 | local clickdetector = ... --your click detector |
2 | local part = ... -- your part |
3 |
4 | clickdetector.MouseClick:Connect( function () |
5 | -- do what you want with your part here |
6 |
7 | 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 |
8 | end ) |
Use a debounce with the ClickDetector's MouseClick
event.
01 | local clickDetector = script.Parent |
02 | local debounce = true |
03 |
04 | local debounceTime = 2.5 --Replace with whatever number you want |
05 |
06 | clickDetector.MouseClick:Connect( function () |
07 | if debounce = = true then |
08 | debounce = false |
09 |
10 | delay(debounceTime, function () |
11 | debounce = true |
12 | end ) |
13 |
14 | --stuff |
15 | end |
16 | end ) |