A Pathfinding system like this, it follows a set path
I have a script for this, however, over time new path bricks get added into the world. The NPC only follows the path that were created prior to the new bricks. So basically , it only follows the old ones, not the newly generated ones.
local NPC = script.Parent
local Waypoints = game.Workspace.Nodes -- folder that contains the waypoint bricks
while true do
for Waypoint=1, #Waypoints:GetChildren() do
NPC.Humanoid:MoveTo(Waypoints[Waypoint].Position)
NPC.Humanoid.MoveToFinished:Wait()
end
end
local NPC = script.Parent
local waypoints = workspace.Nodes -- folder that contains the waypoint bricks
local index = 0
while true do
index += 1
local waypoint = waypoints:WaitForChild(tostring(index), 10) -- 10 is the amount of time to wait before giving up
if waypoint then
NPC.Humanoid:MoveTo(waypoint.Position)
NPC.Humanoid.MoveToFinished:Wait()
else break end
end
This will make the NPC follow points in order, and if there is none left, it waits 10 seconds for more points, otherwise it stops walking.