Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I add a cool down to this script?

Asked by
Simxzn 2
4 years ago
Edited 4 years ago
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

Log in to vote
0
Answered by
Simxzn 2
4 years ago

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)

Ad

Answer this question