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)
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.
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)