How to stop character running animation

I want to prevent the player from moving, and thus anchored their HRP as well as set their WalkSpeed and JumpPower to 0. However, they walk animation continues to play when this function is fired. I originally was unbinding the movement controls, which worked well, but have had to stop doing that, as then the WASD keys become a GameProcessedEvent, which breaks other aspects in my game.
ezgif.com-video-to-gif (14)

return function(active)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	
	local HumanoidRootPart = Character:FindFirstChild('HumanoidRootPart')
	if not HumanoidRootPart then return end
	
	local Humanoid = Character:FindFirstChild('Humanoid')
	if not Humanoid then return end
	
	-- Disable movement
	HumanoidRootPart.Anchored = not active
	
	Humanoid.JumpPower = active and 40 or 0
	Humanoid.WalkSpeed = active and 18 or 0
end
1 Like

Just set the WalkSpeed and JumpPower before anchoring HRP?

4 Likes

The players still running :confused:

1 Like

You might be able to do this with the GetPlayingAnimationTracks function of the humanoid and stopping them all, or changing the state of the humanoid to something other than running

3 Likes

Just add a wait(0.1). Just tested it out.

Set the velocity to Vector3.new() aka 0,0,0?

1 Like

Sorry to bump this, but I recently came across this issue and came across a solution.

Disable the walk and jump power, then anchor, wait(), unanchor, wait(), anchor again.
.without a wait(0.1)
Iā€™m not sure if this works for every application, but it worked for me, and hopefully it can work for you too.
:wink:

-- disable
-- anchor
-- wait()
-- unanchor
-- wait()
-- anchor