How to stop character running animation?

I saw several similar threads but couldn’t find the solution to this simple situation: I want to anchor the character while it’s running, by pressing P:

  1. Run the script below
  2. Start running with the character (key W)
  3. While running, press P (will anchor the character)
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer

UserInputService.InputBegan:Connect(function(Input,GPE)
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.P then
		Player.Character.PrimaryPart.Anchored = true
	end
end)

But the running animation won’t stop:

a

How to stop character running animation?

Edit

I’ve also tried this, but no success:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

UserInputService.InputBegan:Connect(function(Input,GPE)
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.P then
		print("Humanoid:GetState(): ", Humanoid:GetState())
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false)
		Player.Character.PrimaryPart.Anchored = true
	end
end)
2 Likes

I mean you could always make an animation using studio’s animation software thing. Then make an animation where the character is just doing nothing. Then you can make it so that it plays that animation where it is in place. There’s probably an easier method but uh ye.

Anyone?


This is actually a very good question. My only thought is before anchoring the HumanoidRootPart, set the walk speed to 0, and add a very small delay, then anchor. This should stop the character from continuing to walk, giving time for the animation to stop. Let me know how this works.

1 Like

Have you tried with the sample script above?

Try this:


local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

UserInputService.InputBegan:Connect(function(Input,GPE)
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.P then
        for index, part in pairs(Character:GetChildren())do
            if(part:IsA("Part"))then
                part.Anchored = true
            end
        end
	end
end)

Have you tested? I doesn’t work.

The one above only worked for r6, but this one works for all body types now

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

UserInputService.InputBegan:Connect(function(Input,GPE)
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.P then
		for index, part in pairs(Character:GetChildren())do
			if(part:IsA("Part")) or (part:IsA("MeshPart"))then
				part.Anchored = true
			end
		end
	end
end)
1 Like

Thanks, but this will only freeze the current character and will not return the character to its default standing position:
image

Made a new boolean variable that checks the players state. When they press P it freezes, and then P again unfreezes.

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

--New variable
local isFrozen = false

UserInputService.InputBegan:Connect(function(Input,GPE)
	if (Input.KeyCode == Enum.KeyCode.P) and (not isFrozen)then
		for index, part in pairs(Character:GetChildren())do
			if(part:IsA("Part")) or (part:IsA("MeshPart"))then
				part.Anchored = true
			end
		end
		isFrozen = true
	elseif (Input.KeyCode == Enum.KeyCode.P) and (isFrozen) then
		for index, part in pairs(Character:GetChildren())do
			if(part:IsA("Part")) or (part:IsA("MeshPart"))then
				part.Anchored = false
			end
		end
		isFrozen = false
	end
	
end)

After many tests, I think I managed how to create a workaround for this.
It’s not perfect, but it’s a start:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

UserInputService.InputBegan:Connect(function(Input,GPE)
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.P then
		Player.Character.PrimaryPart.Anchored = true -- will not stop the running animation
		wait(0.5)
		Player.Character.PrimaryPart.Anchored = false -- will stop it
		wait(0.5)
		Player.Character.PrimaryPart.Anchored = true -- back to true after stopping the animation
		
	end
end)
2 Likes

I would recommend stopping the walk speed at first then anchoring the humanoid root part what ever is on top is what is starting first so you don’t need to add waits.

Also recommend adding variables to make it easier.

(Line 1: Humanoid.WalkSpeed = 0)
(Line 2: Humanoid.JumpPower = 0)
(Line 3: HRP.Anchored = true)

No needed waits, I know this topic is solved 6 months ago but its just a better way of doing whatever you’re trying to achieve.

2 Likes

Old question, but a good solution is to just get all the running animation tracks inside the players humanoid, and stop them:

local Humanoid = plr.Character.Humanoid
	local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
	for _,v in pairs(ActiveTracks) do
			v:Stop()
	end

Edit: You can actually just set the Humanoids PlatformStand property to true, and then to false whenever you’re done with anchoring the root part.

Tried this and I had to add a small wait for it to work. Thank you though I’ve had this issue for a while now!

1 Like