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

Stop idle and run animations from playing after tool is unequipped?

Asked by 4 years ago
Edited 4 years ago

If you scroll down and look for the unequipped function, that's the part that doesn't work. When I unequip my tool the idle and run animations should stop, but they still play.

Heres a short video of me unequipping it, idk how to use gyazo that well https://gyazo.com/104197d47e30d4cc1c155023619c7dd8

--Variables
humanoid = script.Parent.Parent.Humanoid

Running = script.Parent.Running
Idle = script.Parent.Idle
Attack = script.Parent.Attack

--Loads animations
runAnim = humanoid:LoadAnimation(Running)
idleAnim = humanoid:LoadAnimation(Idle)
attackAnim = humanoid:LoadAnimation(Attack)

--Animation locations
lookForIdle = script.Parent.Idle
lookForRun = script.Parent.Running
lookForAttack = script.Parent.Attack

script.Parent.Equipped:Connect(function() -- basically works fine
    humanoid.Running:Connect(function(speed)
        if speed >1 then
            idleAnim:Stop()
            runAnim:Play()
        else
            idleAnim:Play()
            runAnim:Stop()
        end
    end)
end)


script.Parent.Unequipped:Connect(function() -- doesn't stop my tool animations when unequipped, Error, "Stop is not a valid member of Animation" 
    lookForIdle:Stop()
    lookForRun:Stop()
end)


local debounce = false
script.Parent.Activated:Connect(function() -- Attack, pauses character and plays animation when activated
    if not debounce then
        debounce = true

        humanoid.WalkSpeed = 0
        attackAnim:Play()

        wait(2.5)
        humanoid.WalkSpeed = 16

        debounce = false
    end
end)
0
I am sorry to disappoint you but I can figure it out, bud. rabbi99 714 — 4y
0
:/ User#29785 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The problem is that when you're telling the animation to stop, you are tell the actual animation object and not the animation loaded in a humanoid. It should be fixed below.

also sorry I replied late.


--Variables humanoid = script.Parent.Parent.Humanoid Running = script.Parent.Running Idle = script.Parent.Idle Attack = script.Parent.Attack --Loads animations runAnim = humanoid:LoadAnimation(Running) idleAnim = humanoid:LoadAnimation(Idle) attackAnim = humanoid:LoadAnimation(Attack) --Animation locations lookForIdle = script.Parent.Idle lookForRun = script.Parent.Running lookForAttack = script.Parent.Attack script.Parent.Equipped:Connect(function() -- basically works fine humanoid.Running:Connect(function(speed) if speed >1 then idleAnim:Stop() runAnim:Play() else idleAnim:Play() runAnim:Stop() end end) end) script.Parent.Unequipped:Connect(function() -- doesn't stop my tool animations when unequipped, Error, "Stop is not a valid member of Animation" idleAnim:Stop() runAnim:Stop() end) local debounce = false script.Parent.Activated:Connect(function() -- Attack, pauses character and plays animation when activated if not debounce then debounce = true humanoid.WalkSpeed = 0 attackAnim:Play() wait(2.5) humanoid.WalkSpeed = 16 debounce = false end end)
0
I already tried to do the idleAnim:Stop() and runAnim:Stop(), but it still doesn't disable the animations when I unequip my tool, idk why User#29785 0 — 4y
Ad

Answer this question