Here's the script:
wait() local player = game.Players.LocalPlayer local tool = script.Parent tool.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() local ev = workspace.Events.PunchE ev:FireServer() end) end)
I need it to have a cooldown so if a player spamclicks the event will only get triggered after the cooldown is up.
Use the debounce method:
wait() local player = game.Players.LocalPlayer local tool = script.Parent local CanClick = true -- debounce bool, this will determine if the function can fire (true) or not (false). tool.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() if CanClick then -- same thing as: 'if CanClick == true' CanClick = false -- set the debounce to false to prevent the function from firing local ev = workspace.Events.PunchE ev:FireServer() --COOLDOWN-- wait(.5) CanClick = true end end) end)