How to stop all player animations

Is there any way to stop all player animations to play another one?
after the animation is over everything goes back to normal

17 Likes

Hey RVTGAMERGg!

Using the code below, you can stop all Animations playing on a player’s humanoid.

--
for i,v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
	v:Stop()
end
57 Likes

Humanoid:GetPlayingAnimationTracks() is deprecated

3 Likes

Deprecation means it still works, it just is not recommended for new work. Try out that code, it will still work.

I have no clue what the modern non-deprecated function is to stop all animation tracks.

4 Likes

Ok ,ty for the solution

(No reason for make a big text lol)

1 Like

the new one is very simple
instead of it being a function of humanoid, its a function of Humanoid.Animator

besides that its all the same

8 Likes

reviving this to show a more recent solution, the one @iiCant_Read mentioned above

local humanoid = model:FindFirstChildOfClass("Humanoid") or model:FindFirstChildOfClass("AnimationController")
local animator = humanoid:FindFirstChildOfClass("Animator")
for i,v in ipairs(animator:GetPlayingAnimationTracks()) do
	v:Stop()
end

this code works for both characters and non-character rigs (like lamps) and isnt deprecated

23 Likes

Both of the solutions posted don’t work in my case:

It’s hard to reproduce this animation bug, but it only seems to happen when I’m going really fast and change to or from walking.

Commands used:
for _,v in workspace.GFink.Humanoid:GetPlayingAnimationTracks() do v:Stop() end
for _,v in workspace.GFink.Humanoid.Animator:GetPlayingAnimationTracks() do v:Stop() end

3 Likes

It might be that you have more than one thing named “GFink” in your workspace, for example an NPC clone or something.

Edit: You are missing the pairs/ipairs

Try this:
for _,v in pairs(workspace.GFink.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end
for _,v in pairs(workspace.GFink.Humanoid.Animator:GetPlayingAnimationTracks()) do v:Stop() end

1 Like

I appreciate the response, and I figured the duplicate GFink thing was worth a check — but no luck.

In regards to the pairs thing, I would’ve seen an error if that didn’t work. Check this post out:

2 Likes

Since the current topic is outdated and none of the solutions seemed that good or worked for me, here is another solution to this

	local animate = player.Character:FindFirstChild("Animate", true)
	for i,v in pairs(animate:GetDescendants()) do
		if v:IsA("Animation") then
			v.AnimationId = 0
		end
	end
	animate:Destroy()

(This deletes all animations which is good for what I’m intending to use this for)

4 Likes

I’m stopping the animation of a player via server script using that:

local player = game:GetService("Workspace"):FindFirstChild("PLAYER_NAME_HERE")
if player then
    local humanoid = player:FindFirstChild("Humanoid")
    if humanoid then
        local animator = humanoid:FindFirstChild("Animator")
        if animator then
            local animations = animator:GetPlayingAnimationTracks()
            for i = 1, #animations do
                animations[i]:Stop()
            end
        end
    end
end

So you can incapsulate this in a function then iterate it for all players like:

local function StopAnimation(player)
    local player = game:GetService("Workspace"):FindFirstChild(player.Name)
    if player then
        local humanoid = player:FindFirstChild("Humanoid")
        if humanoid then
            local animator = humanoid:FindFirstChild("Animator")
            if animator then
                local animations = animator:GetPlayingAnimationTracks()
                for i = 1, #animations do
                    animations[i]:Stop()
                end
            end
        end
    end
end

local players = game:GetService("Players"):GetPlayers()
for i = 1, #players do
    StopAnimation(players[i])
end
2 Likes

Rather than doing it from the Humanoid, you do it from the Animator. You do nothing else.

2 Likes