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

On tool.Activated, debounce cooldown will not work?

Asked by 6 years ago

The LocalScript is inside a tool. It is supposed to choose a random animation and play it. The random and animations work but the cooldown i applied doesnt seem to work. Any Help? Here's what you need to see:

debounce = false



tool.Activated:Connect(function()

if debounce == false then   
    debounce = true

 local attack1 = hum:LoadAnimation(script.Animation1)
local attack2 = hum:LoadAnimation(script.Animation2)

local chooseattack = math.random(1,3)

if chooseattack == 1 then

   attack1:Play()

end

if chooseattack == 2 then

   attack2:Play()

end

wait(1)
debounce = false
end

end)

0
I dunno since you didn't indent correctly, man. hiimgoodpack 2009 — 6y
0
sorry im still learning to script so i dont really know how to indent right, are you sure you dont have a sliver of a thought, how to help me? taunter165 30 — 6y

1 answer

Log in to vote
0
Answered by
iddash 45
6 years ago
Edited 6 years ago

I not that sure if this will work but try it

debounce = false

tool = script.Parent --you hadnt set this to anything
hum = game:GetService("Players").LocalPlayer.Character.Humanoid -- you hadnt set this either



local anims = {script.Animation1,script.Animation2}--stores the animations in an array

 -- gets a random number from 1 to 2

tool.Activated:Connect(function()
    if not debounce then   -- if debounce is false
        debounce = true --sets it to true
        local chooseattack = math.random(2)
        local animation = hum:LoadAnimation(anims[chooseattack]) --this will load a random animation, from the array, into the player
        animation:Play() -- plays it
        wait(1)--waits 1
        debounce = false--sets debounce to false
    end

end)


Ad

Answer this question