Hi, I have a problem. so I have this pathfinding script that I’m planning on further on making it follow players. but firstly I have a problem. so I have this animation for walking and I’m trying to use it on the npc but the problem is while the npc is moving the animation doesn’t work. it just freezes in place. I figured maybe my if statements are wrong. so please help here’s the script.
local pf = game:GetService("PathfindingService")
local path = pf:CreatePath()
local torso = script.Parent.UpperTorso
local hum = script.Parent.Humanoid
path:ComputeAsync(torso.Position, Vector3.new(1,0,1))
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
hum:MoveTo(waypoint.Position)
hum.MoveToFinished:Wait(2)
end
script.Parent.Humanoid.Running:Connect(function(speed)
local attackrun = script.Parent.Humanoid.Animator:LoadAnimation(script.Fernand_Run_Attack)
local run = script.Parent.Humanoid.Animator:LoadAnimation(script.Fernand_Run_Docile)
if script.Parent.Docile.Value == false then
if speed > 0 then
attackrun:Play()
else
attackrun:Stop()
end
end
if script.Parent.Docile.Value == true then
if speed > 0 then
run:Play()
else
run:Stop()
end
end
end)
video: