For some reason, the PathfindingService path isn't making anything in the table for the NPC to move to. Please help!
while true do
local pathfindingService = game:GetService("PathfindingService")
local origin = mytorso.Position
local old = hum.Health
local mode = findrandomRally()
hum.HealthChanged:Connect(function()
if hum.Health < old then
mode = findnearestHumanoid()
end
end)
if mode ~= nil then
local torso = mode:FindFirstChild("Torso") or mode:FindFirstChild("HumanoidRootPart")
local path = pathfindingService:FindPathAsync(mytorso.Position, torso.Position)
-- calculate new
local points = path:GetPointCoordinates()
for _, point in pairs(points) do
script.Parent.Humanoid:MoveTo(point)
script.Parent.Humanoid.MoveToFinished:Wait()
end
end
wait(2)
end
