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

why doesnt the debounce affect this animation?

Asked by
Jumbuu 110
8 years ago
local clicked = false
tool.Activated:connect(function()
    if not clicked then
        clicked = true
    if swing1 and humanoid and humanoid.Health > 0 then
        local swingAnim = humanoid:LoadAnimation(swing1)
        swingAnim:Play()
    end
    clicked = false
    end
end)

1 answer

Log in to vote
1
Answered by 8 years ago

The method Play only plays the animation but also continues the code so you are resetting the denounce not waiting till the animation finishes.

local clicked = false
 local swingAnim  = nil -- store animation
tool.Activated:connect(function()

--check animation status
if swingAnim   ~= nil then
    clicked = swingAnim:IsPlaying () -- now check that the animation has finished
end

    if not clicked then
            clicked = true
            if swing1 and humanoid and humanoid.Health > 0 then
                local swingAnim = humanoid:LoadAnimation(swing1)
                swingAnim:Play()
            end
        -- clicked = false we now don't need this
    end
end)

Hope this helps comment if you need any more info

0
turns out it was because i didnt add a wait() Jumbuu 110 — 8y
0
just a note but wait() is not exact u chould use tick() to accreatly mesure time User#5423 17 — 8y
Ad

Answer this question