My Character keeps playing his walking animation even while idle

How can I fix this? My Character keeps playing his walking animation even while idle and I don’t know how to script this.

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local idleAnim = Instance.new("Animation")
idleAnim.AnimationId = "rbxassetid://7208722455"
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)

local runAnim = Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://8562381041"
local runAnimTrack = humanoid.Animator:LoadAnimation(runAnim)

local jumpAnim = Instance.new("Animation")
jumpAnim.AnimationId = "rbxassetid://8547783411"
local jumpAnimTrack = humanoid.Animator:LoadAnimation(jumpAnim)

local JumpSound = Instance.new("Sound")
JumpSound.SoundId = "rbxassetid://8396408200"
JumpSound.Volume = 2.7
JumpSound.Parent = humanoid.Parent:WaitForChild("Torso")


idleAnimTrack:Play()

humanoid.Running:Connect(function(speed)
	if speed == 0 then
		idleAnimTrack:Play()
	elseif speed > 0 then
		runAnimTrack:Play()
	else
		runAnimTrack:Stop()		
		
		idleAnimTrack:Play()
	end
end)

humanoid.Jumping:Connect(function(joe)
	jumpAnimTrack:Play()
	
	if joe then JumpSound:Play() end
end)
1 Like

Try and see if this works.

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		runAnimTrack:Play()
        idleAnimTrack:Stop()
	else
		runAnimTrack:Stop()		
		idleAnimTrack:Play()
	end
end)
1 Like

This worked yes, but now whenever I jump, the run animation started when I go back down.

you can add a if to check if the character is jumping.

Do you know why this isn’t working?

the running and idle anim doesn’t play at all.

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local idleAnim = Instance.new("Animation")
idleAnim.AnimationId = "rbxassetid://7208722455"
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)

local runAnim = Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://8562381041"
local runAnimTrack = humanoid.Animator:LoadAnimation(runAnim)

local jumpAnim = Instance.new("Animation")
jumpAnim.AnimationId = "rbxassetid://8547783411"
local jumpAnimTrack = humanoid.Animator:LoadAnimation(jumpAnim)

local JumpSound = Instance.new("Sound")
JumpSound.SoundId = "rbxassetid://8396408200"
JumpSound.Volume = 2.7
JumpSound.Parent = humanoid.Parent:WaitForChild("Torso")


idleAnimTrack:Play()

humanoid.Running:Connect(function(speed)
	if humanoid.Jumping == false then
		if speed > 0 then
			runAnimTrack:Play()
			idleAnimTrack:Stop()
		else
			runAnimTrack:Stop()		
			idleAnimTrack:Play()
		end
	end
end)

humanoid.Jumping:Connect(function(joe)
	jumpAnimTrack:Play()
	
	if joe then JumpSound:Play() end
end)

Why don’t you just change the characters default animations?

What? What do you mean? why would I wan to build off of r6 or r15 animations that don’t work for this rig?

humanoid.Running is an event so it will probably never be evaluated as false

1 Like