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

Trying to get an Animation to stop playing?

Asked by 7 years ago

Okay so, the animation is set to loop, I'm just trying to get the Animation to stop playing after once the character stops moving. I have the if Anim then Anim:Stop() to stop it from playing upon player join

local Anim
humanoid.Running:Connect(function(speed)
    CurrentAnim = "Walking"
    if speed > 0 then
       local Animation = Instance.new('Animation')
        Animation.AnimationId = WalkAnimID
       Anim = humanoid:LoadAnimation(Animation)
        Anim:Play()
    else
        if Anim then
    Anim:Stop()
    if speed == 0 then
        Anim:Stop()
    end
 CurrentAnim = ""
        end
    end
end)
1
I would personally use GetPlayingAnimationTracks and stop all animations made from the Running animation ID. It helps stop the animation glitches. Reply if you'd like an example in answers Bellyrium 310 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Simply call the GetPlayingAnimationTracks method on the humanoid, and set a pointer to what it returns like so:

local Animations = humanoid:GetPlayingAnimationTracks();

Then, go through them one by one:

for Key, Value in next, Animations do --Key is the current animation # you are on & Value is the pointer to the current animation
--\\Code//--
end;

Now call the stop method on 'value':

Value:Stop();
Ad

Answer this question