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

How can I trace an AnimationTrack while it is looping?

Asked by 9 years ago

I have this animation loop that starts when a tool is equipped, and I want to break out of the loop when the tool is unequipped. How can I return the AnimationTrack so that I am able to use the Stop() function on it? Currently I switch out the tool holding anim in the character by changing the animationId, but I can not find the loop again.

^ I know this was a terrible description of my problem, but I hope you understand the question and are able to help me (:

Thanks!

1 answer

Log in to vote
1
Answered by 9 years ago

Use multiple animations in the character, make a variable of the AnimationTrack of each. Use the Unequipped event to disable the animation(s).

Tool.Equipped:connect(function(mouse)
    char = workspace:FindFirstChild(game.Players.LocalPlayer.Name)
    if char then
        anim1 = char:LoadAnimation(char.Anim1)
        anim1:Play()
    end
end)

Tool.Unequipped:connect(function(mouse)
    if anim1 then
        anim1:Stop()
    end
end)
Ad

Answer this question