Custom Character Error

I have this custom character i made that i want to be the player for my game:

image

These are his joints:
image

And this is his animation script:

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

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)

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

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

It’s kind of working, i can play with it normally but the animations are not working correctly, i made them in the animation editor of rolox studio and they were just fine, but when i play this is what happens:

robloxapp-20220121-2148271.wmv (630.4 KB)

Does anybody know how to fix that?

I’m not sure if this is the problem as I’m not an animator or handle animations much, but I think you meant to put this else statement on the if speed > 0?

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

you got the lines mixed up with else