Everyone says to do this to check for movement, but it won't work

image

This is my lizard monster.
Fully rigged, has a humanoid, can load and play animations.

I have this animate script.

--loading all animations
local humanoid = script.Parent:WaitForChild("Humanoid")
local walk = humanoid.Animator:LoadAnimation(humanoid.Animator.walk)
local idle = humanoid.Animator:LoadAnimation(humanoid.Animator.idle)
local eyes = humanoid.Animator:LoadAnimation(humanoid.Animator.idleEyes)
local mouth = humanoid.Animator:LoadAnimation(humanoid.Animator.idleMouth)
local tail = humanoid.Animator:LoadAnimation(humanoid.Animator.idleTail)

--the second we load, play idle animation
idle:Play()

--set up events to play and stop walking animation
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	print("setup")
	if humanoid.MoveDirection.Magnitude > 0 then
		if walk.IsPlaying == true then 
			return 
		end
		print("walking")
		walk:Play();
	else
		walk:Stop();
	end
end)

This works right up until the event. This is the script that basically every result I check says to use when trying to detect humanoid movement. Through testing, I can confirm that code after the event does indeed run, and the print statement “setup” never prints, meaning the event is never actually fired.
What am I doing wrong?

Edit: Further testing seems to show that yes, the issue does indeed seem to be that movedirection is simply not changing. Why?

NOTE: If it matters, this is in a server script inside the lizard

I’m not sure if MoveDirection should work or not, but I personally prefer to use velocity.

if humanoid.Velocity.Magnitude > 0.1 then
-- 0.1 might be too much or not enough, try to experiment with it

Another thing, because walk.IsPlaying is a boolean, you don’t need to include the “== true” :slight_smile:

Hello!

I can confirm that from testing, GetPropertyChangedSignal("MoveDirection") does not fire for NPCs and MoveDirection doesn’t even change. This was also addressed in this post: Humanoid MoveDirection stays at 0,0,0 despite moving. I tried @BriefYayyayyay’s method and yes while this does work for determining if the Lizard is moving, it doesn’t work in the form of an event; just as a check. You’ll need to use something else like manually telling the animate script what animation to use through something like a BindableEvent. Hope you can get it working!

1 Like