I have a script that loads an animation (Humanoid:LoadAnimation
) into the player’s humanoid. The animation is looped
and it’s priority is movement
. Is there anyway I can stop the animation?
I tired that and it didn’t seem to work. I tried animation:Stop()
To better help it would be nice to see the code that’s not working. The :Stop() function should work but you have to be referencing the AnimationTrack correctly.
I have no idea if this will work but you should try to set the looped property of the track to false before trying the :Stop() method
to get a table of the currently running animations in a humanoid you would run
local animtracks = player.Character.Humanoid:GetPlayingAnimationTracks()
and to stop the animation you would do this as such
for i,v in pairs(animtracks) do
if v.Name == "RunAnim" then
v:Stop()
end
end
Are you sure you’re stopping the correct animation value? If you know you are, are you sure that you aren’t running it again? As others said, showing us your code would really help us to solve your problem.
You use AnimationTrack’s :Stop() function to stop an animation that is currently being played on a Humanoid or AnimationController. To get the AnimationTrack
, you must have a reference to the AnimationTrack
that you previously created from a function like Humanoid:LoadAnimation(Animation Object).
You can also grab the animation if you no longer have a reference to it if it’s playing from this useful function under any Humanoid
or AnimationTrack
here, meet the function GetPlayingAnimationTracks.
Example usage of both:
local Animation = script.Animation -- Animation object
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
wait(1)
AnimationTrack:Stop()
local Animation = script.Animation -- Animation object
for _, AnimationTrack in pairs(Humanoid:GetPlayingAnimationTracks()) do
if AnimationTrack.Name == Animation.Name then
AnimationTrack:Stop()
break -- Break the loop, we already found and stopped the specified animation.
end
end