When i use PathfindingService, the NPC dosent even reach me even when his walkspeed is bigger than 16.
This is the GIF: https://gyazo.com/13a5b3c2a759e4218b59c906db1a67c9
and heres the full chasing script:
function chase()
while true do
if not walking then
for i,v in pairs(workspace:GetChildren()) do
if not v:findFirstChild("Zombie AI") and v:findFirstChildOfClass("Humanoid") and v:findFirstChild("Head") then
if (v:findFirstChild("Head").Position - npc.Head.Position).magnitude < sight then
canrandomwalk = false
local thehumanoid = v:findFirstChildOfClass("Humanoid")
while (v:findFirstChild("Head").Position - npc.Head.Position).magnitude < sight and thehumanoid.Health > 0 do
npchumanoid.WalkSpeed = 17
local path = game:GetService("PathfindingService"):ComputeRawPathAsync(torso.Position, v:findFirstChild("Head").Position, 200) --find the path from scp's torso to victims head
local waypoints = path:GetWaypoints() --get the every point of the path
local heartbeat = game:GetService('RunService').Heartbeat
local pointnumber = 0
if path.Status == Enum.PathStatus.Success then
for q,w in pairs(waypoints) do --for every point existing..
local allow = 0
npchumanoid:MoveTo(w.Position) --...walk to the point
while (torso.Position - w.Position).magnitude > 4 and allow < 25 do
allow = allow + 1
heartbeat:wait()
end
if w.Action == Enum.PathWaypointAction.Jump then
npchumanoid.Jump = true
end
npchumanoid.WalkToPoint = v:findFirstChild("Head").Position
end
end
end
else
canrandomwalk = true
end
end
end
end
wait()
end
end

1 comment
use the second argument to npchumanoid:MoveTo(w.Position). It will follow the player instead of using the path finding service. You should be using path finding with care and not within a quick loop like this.