Walking/Running animation not changing until player stops moving

The Running animation changes when the player dashes forward while holding W, however it is supposed to change back when the user stops holding W or other stuff happens (attacking, stunned, etc…), but the animation wont change until the player stops moving.

function Run()
	Front = 1
	dec = 0

	chr.Animate.walk.WalkAnim.AnimationId = "rbxassetid://15992728336"
	chr.Animate.run.RunAnim.AnimationId = "rbxassetid://15992728336"

	local DashVelocity = Instance.new("BodyVelocity")
	DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
	DashVelocity.P = 9e9
	DashVelocity.Parent = humrp

	delay(config.FrontTime, function()
		dec = 1

	repeat wait()
		DashVelocity.Velocity = humrp.CFrame.LookVector * (Front * config.FrontSpeed) + humrp.CFrame.RightVector * (0 * config.FrontSpeed)
	until dec == 1

	Values.Status.Dashing.Value = false

	delay(config.SideCD, function()
		Sidedb = false
	running = true
	print("running = true")
	hum.WalkSpeed = Values.WalkSpeed.Value * 1.25
	repeat wait()
		if UIS:IsKeyDown(Enum.KeyCode.W) and
			statements.stunned.Value ~= true and 
			statements.ragdolled.Value ~= true and 
			statements.blocking.Value ~= true and 
			statements.attacking.Value ~= true
			running = false
	until running == false
	print("running = false")
	chr.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=180426354"
	chr.Animate.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=180426354"
	hum.WalkSpeed = Values.WalkSpeed.Value
1 Like

This might have to do with the Animate script still using the old animation while you are still moving. (I’m just speculating here, as I don’t use the default Roblox Animate Script for handling custom animations.)

Have you tried using an loaded AnimationTrack for the Walking/Running Animation?

1 Like

So you mean to create an animation instance?

local Anim = Instance.new("Animation")
Anim.AnimationId =

and so on like that?

local Animation = Instance.new("Animation")
Animation.AnimationId = "your animation id"

local Animator = Humanoid:FindFirstChildWhichIsA("Animator")
local Track = Animator:LoadAnimation(Animation)

1 Like

The Animator is a replacement for Humanoid, as loading animations in Humanoid is deprecated now, so I recommend using this instead.

Having to repeatedly change the AnimationId everytime a player stops or begins running is incredibly inefficient, I have tried this before but ended up failing terribly/ended up with lots of bugs.


Would that mean this is also deprecated?

for i,v in pairs(Animations) do
	local Anim = Instance.new("Animation")
	Anim.AnimationId = v
	Anim = hum:LoadAnimation(Anim)
	Animations[i] = Anim

Also, what does code being deprecated effect?

Deprecated code is an outdated code that will probably break or get removed in the future, so it’s best to use an alternative
You can still use humanoid for animations, but I would personally prefer using animator as it is not deprecated.

Offtopic, why are you creating an instance inside of a loop?

1 Like

Making multiple instances for each animation, or do I not need to do that?

Animations = {
	["DashRight"] = 'rbxassetid://15991973453';
	["DashLeft"] = 'rbxassetid://15991972075';
	["DashFront"] = 'rbxassetid://15991974139';
	["DashBack"] = 'rbxassetid://15991971069';

for i,v in pairs(Animations) do
	local Anim = Instance.new("Animation")
	Anim.AnimationId = v
	Anim = hum:LoadAnimation(Anim)
	Animations[i] = Anim

well if it works, then don’t touch it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.