TO MAKE IT MORE SIMPLE HERE IS A MODEL OF THE AI:
https://web.roblox.com/library/8293330612/Test
What could be happening is in the code there is a for i, v in pairs()waypoints do this is causes it to repeat waypoint creation. This means it will not recreate the path therefore going to the players last location or it could be there is a humanoid.MoveToFinished:Wait() at line 32 stopping the script making it un able to repeat the path after removing the humanoid.MoveToFinished:Wait() it will constantly update the path but travel in a straight line towards the player
here is the full script (I didn't make the torso finding bit) I have had a few try's at fixing which I'm doing right now but I struggle to find a fix
local pathService = game:GetService("PathfindingService")
local humanoid = script.Parent.NOOB
humanoid.Parent.PrimaryPart:SetNetworkOwner(nil)
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 800
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("HumanoidRootPart")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
local function move(v)
humanoid:MoveTo(v.Position)
humanoid.MoveToFinished:Wait()
end
local path
while true do
wait(0.1)
local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
if target ~= nil then
path = pathService:CreatePath()
path:ComputeAsync(script.Parent.HumanoidRootPart.Position, target.Position)
local waypoints = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then
for i,v in pairs(waypoints) do
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CanCollide = false
part.Material = Enum.Material.Neon
part.Position = v.Position
part.Size = Vector3.new(0.6,0.6,0.6)
part.Shape = "Ball"
if v.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
move(v)
end
end
end
end

1 comment
one of my ideas of how to fix this was to pick up and repeat getting one waypoint at a time instead of multiple but that could cause the ai to constantly pause and I struggled to work out how to do that