Walking animation not running

No clue why this isn’t working, thought this would be easy and simple but it just wont run, heres the script

local hum = script.Parent.Humanoid
local animator = hum:FindFirstChildOfClass("Animator")

local animationT = animator:LoadAnimation(script.Run.MonsterRun)
animationT.Looped = true
animationT.Priority = Enum.AnimationPriority.Core
animationT:AdjustSpeed(0.5)

local Running = false

-- Function to check if the NPC is moving
local function checkMovement()
	if hum.MoveDirection.Magnitude > 0 then
			animationT:Play()
	end
end

game:GetService("RunService").Heartbeat:Connect(checkMovement)
1 Like
if not animationT.IsPlaying then
	animationT:Play()
end

try this

still not working, i won’t get an error but it just doesnt play

Instead of checking every heartbeat. Use the Task Scheduler Connect a event to when the Humanoid’s MoveDirection Changes. Then check Magnitude. Also, double check your asset id. This could also be a cause.

1 Like

could you give me a little script implementing task scheduler because ive never used it or heard of it

also the npc is using pathfinding which updates every second, i dont know if that would be an issue.

Sorry, the Task Scheduler is a internal part of Roblox that manages connections, heartbeats, etc. Sorry for the complicated wording. Here is some documentation: Task Scheduler

local YourHumanoid  -- Humanoid

function Action()
	print("Move Direction Changed")
end

YourHumanoid:GetPropertyChangeSignal("MoveDirection"):Connect(Action)

That should work correctly!

maybe try to use a pcall i guess