(SOLVED) Humanoid.MoveDirection.Magnitude Is always 0

Hey guys, I’m @refightx. I’m trying to make an animal system, but I’m having trouble with one line.

while task.wait(LoopTime) do

	for i, Animal in pairs(Wildlifefolder:GetChildren()) do
		
		if Animal.Humanoid.Health == 0 then print("Here") return end
		
		local moveanimalmodule = require(Animal.MoveAnimalModule)
		print(Animal.Humanoid.MoveDirection.Magnitude)
		if Animal.Humanoid.MoveDirection.Magnitude > 0 then coroutine.wrap(LoopThroughPlayers)(Animal, moveanimalmodule) return end
		
		coroutine.wrap(LoopThroughPlayers)(Animal, moveanimalmodule)

		if Attacking == true then return end

		PickRandomWaypoint(Animal)

		if path.Status == Enum.PathStatus.Success then
			
			coroutine.wrap(LoopThroughPlayers)(Animal, moveanimalmodule)
			coroutine.wrap(moveanimalmodule.MoveThroughAnimalWaypoints)(path)

		else
			warn("Not working")
		end

	end

end

the problem is these 2 lines.

print(Animal.Humanoid.MoveDirection.Magnitude)
if Animal.Humanoid.MoveDirection.Magnitude > 0 then coroutine.wrap(LoopThroughPlayers)(Animal, moveanimalmodule) return end

It is always 0 no matter what.

My model is properly rigged, it does move to where I want it to go, Im using :MoveTo(), And it is a custom rig. Is there any other way to see if the model is moving?

Any help is appreciated. Thank You!

1 Like

you could try use Animal.PrimaryPart.Velocity.Magnitude. The down side is that it is deprecated, but I use it and it works fine. Can the player push the model around? If so, this approach isn’t very reliable.

I say run a loop that grabs the position of the animal, then wait a couple seconds and check the position again, then you can get the magnitude of both positions, you could make a threshold of 1 or 2 and if its above that then you know the animal is moving!

Humanoid.MoveDirection is a property set by the PlayerScripts and reflects user input intent (i.e. WASD presses or controller joystick direction), not current movement. You might want AssemblyLinearVelocity of the HumanoidRootPart?

Oh, thank y’all for the ideas, but I figured this out yesterday. I had a Zpos and an Xpos. I subtracted the Animals current x and z pos from the Lastxpos and lastzpos. If either of them was bigger than 0.5 than I assume the animal was moving.