Can't stop animation?

Code:

local Animator = Character.Humanoid:FindFirstChildOfClass("Animator")
if Animator then
	local AnimationTrack = Animator:LoadAnimation(script.Animation)
	AnimationTrack.Looped = false
	AnimationTrack:Play()
	AnimationTrack.Stopped:Wait()
	AnimationTrack:Stop()
end

Result:

Does anyone know why the animation isn’t stopping?

If you used moon animator, maybe you turned on loop by accident.
This might be the case for roblox default animator but I don’t animate and don’t know if it has a loop animation feature.
Anyway hope this helped.

Should it matter if the animation is looped if I am using Animation:Stop() AND setting looped to false?

Ive read the code and where it says Wait()

local AnimationTrack = Animator:LoadAnimation(script.Animation)
	AnimationTrack.Looped = false
	AnimationTrack:Play()
	AnimationTrack.Stopped:Wait() -- Here
	AnimationTrack:Stop()

Try to put a number, maybe that works.

Using :Wait() on an event causes the script to yield until said event has fired. In this case, the script waits until the animation has stopped before teleporting the player, as seen in the video. This is working perfectly functionally.

I do not know then , sorry for waiting your time.

hello, it’s been a long time, but if anybody or you are still having this problem, another way to solve it is the following script;

local AnimationTracks = humanoid:GetPlayingAnimationTracks() -- Get all playing animations in humanoid
for i, v in pairs(AnimationTracks) do
	if v.Name == "MyAnim" then -- Change here to the name of your anim
		v:Stop()
        print(v.Name) -- You can see the stopped anim name
	end
end

I hope it worked for you guys, I couldn’t find another way to stop the animations that don’t stop.
it’s a local script I don’t try this in server side before :thinking:

1 Like