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 10 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 10 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).

01Tool.Equipped:connect(function(mouse)
02    char = workspace:FindFirstChild(game.Players.LocalPlayer.Name)
03    if char then
04        anim1 = char:LoadAnimation(char.Anim1)
05        anim1:Play()
06    end
07end)
08 
09Tool.Unequipped:connect(function(mouse)
10    if anim1 then
11        anim1:Stop()
12    end
13end)
Ad

Answer this question