Monster not playing animation

I’m trying to make the monster only play an animation when it’s moving.

The monster will not play the animation, because MoveDirection is not changing.

I have tried using MoveToPoint and MoveToPart but neither of them work for what I’m attempting to do

There is no error coming through the output.

local playing = false

while true do	
	local animator = script.Parent.Humanoid:WaitForChild("Animator")
	local animationTrack = animator:LoadAnimation(script.Parent.Humanoid.Walk)
	if script.Parent.Humanoid.MoveDirection.Magnitude > 0 then
		print("No")
		if animator ~= nil then
			if playing == false then
				print("Playing")
				playing = true
				animationTrack:Play()
				animationTrack.Stopped:Wait()
				playing = false
			
			end
			

		end

	else
		print("Stopping")
		animationTrack:Stop()
		playing = false
	end
wait()
end

Video:

If you need any more info about the script just ask.

What you could do is have an event for the humanoid when its running there’s already an event for that

local hum = blalbalba
hum.Running:Connect(function(speed)
    if speed > 0 then
        print("We are running")
    else
        print("We are not running")
    end
end)

and if it’s not still playing assuming the code you implemented is correct then the animation might be the problem