AI Humanoid returning 0 for MoveDirection.Magnitude

I’m trying to make an AI that, when moving, triggers an animation. I was told MoveDirection.Magnitude is the best way to go about this. However, when tested the MoveDirection.Magnitude stays at 0 (even when moving). Here’s my code:

game:GetService("RunService").Stepped:Connect(function()
	if janitor.Zombie.MoveDirection.Magnitude == 0 then
		idleAny:Play()
		walkingAny:Stop()
		footstepSound:Stop()
	elseif janitor.Zombie.MoveDirection.Magnitude > 0 then
		walkingAny:Play()
		idleAny:Stop()
		footstepSound:Play()
	end
end)
1 Like

Is this a server script? MoveDirection can only be used on the client.

Do humanoid.Movedirection, not model.Movedirection

Edit: Oops didn’t mean to reply to you.

I was referring to humanoid.MoveDirection, though. humanoid.MoveDirection is not replicated and can only be read accurately on the client.

i’d recommend not checking the magnitude of the movedirection the magnitude of the torso or rootpart.