How do I make a cooldown for this
script.Parent.Activated:Connect(function()
game.ReplicatedStorage:WaitForChild("throw"):FireServer()
end)
How do I make a cooldown for this
script.Parent.Activated:Connect(function()
game.ReplicatedStorage:WaitForChild("throw"):FireServer()
end)
local buttonCooldown = false
script.Parent.Activated:Connect(function()
if not buttonCooldown then
-- Set buttonCooldown to true to prevent the button from being pressed again
buttonCooldown = true
-- Fire the "throw" remote event
game.ReplicatedStorage:WaitForChild("throw"):FireServer()
-- Wait for 2 seconds before allowing the button to be pressed again
wait(2)
-- Set buttonCooldown back to false to allow the button to be pressed again
buttonCooldown = false
end
end)
Replace this with task.wait()
.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.