Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I add a cool down to this script?

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
        animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
        animation:Play()
    end)
end)

script.Parent.Unequipped:Connect(function()
        animation:Stop()
end)

1 answer

Nevermind, I found a fix

Debounce = false

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
	if not Debounce then
		Debounce = true        
		animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
        animation:Play()
		wait(.6)
		Debounce = false
	end

    end)
end)

script.Parent.Unequipped:Connect(function()
        animation:Stop()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.