How to have constant loop of animations playing

I’m just using 2 of the defualt idle animations, and have them play when I need to stop any other aniamtion playing.

function Animations.Stop(humanoid)
	local Idle1 = CreateAnimation(AnimationIDs['Idle1'])
	local Idle2 = CreateAnimation(AnimationIDs['Idle2'])

	spawn(function()
		while wait() do
			humanoid:LoadAnimation(Idle1):Play()
			wait(4)
			humanoid:LoadAnimation(Idle2):Play()
			wait(4)
		end
	end)
end

However, it’s kinda clunky. As idk how long each animation lasts and I tried .Stopped but since the animation is looped, it nevers stops :confused: Any ideas how I can easily get this working

function Animations.Stop(humanoid)
	local Idle1 = CreateAnimation(AnimationIDs['Idle1'])
	local Idle2 = CreateAnimation(AnimationIDs['Idle2'])
    local anim1, anim2 = humanoid:LoadAnimation(Idle1), humanoid:LoadAnimation(Idle2)

	spawn(function()
		while wait() do
			anim1:Play()
			wait(4)
                anim1:Stop()
			anim2:Play()
			wait(4)
                anim2:Stop()
		end
	end)
end

I am not fully sure if this works, but have you tried to animate it like this? Let me know if you run into any further issues.

Problem with that is it’d still cause issues, as one of the idle animations has the player turn and look over their should kinda, and if you stop it mid turn they glitch back

Oh, why don’t you use the .Length property of the animationtrack?

wait(anim1.Length)
wait(anim2.Length)
1 Like

Or you could forget using wait() and just :Wait() upon animTrack.DidLoop:

anim1.DidLoop:Wait()

This’ll fire when it moves to loop again, but then of course you can :Stop() it.

It is really not that hard. If you insert every animation track they’re using into a table, then you can just use the :Stop() method to stop all animations.

You can get every animation that is getting played by the player with humanoid:GetPlayingAnimationTracks