Answered by
2 years ago Edited 2 years ago
Solution
I recommend using a debounce instead. A debounce is like a toggle of whether you should do this or not. It is crucial if you want to set up a cooldown.
Problem
The reason why your script isn't working is because you're only connecting MouseButton1Click
every 1 second. Connecting the event makes it so that the function you connected to the event will call whenever the event is fired.
Final Script
Normal Script inside the button:
01 | local button = script.Parent |
02 | local player = button:FindFirstAncestorOfClass( "Player" ) |
04 | player = button:FindFirstAncestorOfClass( "Player" ) |
09 | button.MouseButton 1 Click:Connect( function () |
13 | local leaderstats = player:WaitForChild( "leaderstats" ) |
14 | local Clicks = leaderstats:WaitForChild( "Clicks" ) |
17 | task.delay( 1 , function () |
Thanks @xInfinityBear for the suggestion to not use RemoteEvents!