Issues with Idle Animation

I’m currently trying to get an idle animation for my custom starter character model, but it only happens when I walk.

Here is the script:

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

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		if not idleAnimTrack.IsPlaying then
			idleAnimTrack:Play()
		end
	else
		if idleAnimTrack.IsPlaying then
			idleAnimTrack:Stop()
		end
	end
end)

Noticing further I do have the idle animation loaded, but I can’t figure out how to change the rest in order to play the animation when the player is standing still.

Any help or suggestions are greatly appreciated. :smiley:

Well for one you should try changing this:

if speed > 0 then

to this:

if speed <= 0 then
1 Like

You play the animation when the speed > 0. That means you are moving. Try speed < 1

1 Like

Also, the better approach is to play the animation with a priority of “idle” so that it plays when movement does not. You will have to disable any Animate script which will also try to play idle animations.

1 Like

Worked! Thank you for the help! :slightly_smiling_face:

1 Like