#Make a npc walk to different parts forever (pathfinding)

18 messages · Page 1 of 1 (latest)

humble rock
#

so im trying to make a pathfinding script to where my npc can walk around to these different parts over and over but when i use the getChildren() function it doesnt work

script(in npc model)

local npc = script.Parent
local hum = npc:WaitForChild("Humanoid")
local PathfindingService = game:GetService("PathfindingService")

local wayPoints = game.Workspace.Waypoints

local path = PathfindingService:CreatePath()
path:ComputeAsync(npc.HumanoidRootPart.Position, wayPoints:GetChildren().Position)

for _, waypoint in pairs(path:GetWaypoints()) do 
    npc.Humanoid:MoveTo(waypoint.Position)
    npc.Humanoid.MoveToFinished:Wait()
end
hushed crypt
#

getchildren returns a table

thick thunderBOT
#

studio** You are now Level 10! **studio

hushed crypt
#

so you cant call .Position on it

#

.Position is only for instances

#

not only that you should know if you check output

haughty stirrup
somber cliff
haughty stirrup
#

no u

somber cliff
#
local function WalkToStuff()
  for _, ...
  ...
  WalkToStuff()
end

Because recursive is cool

somber cliff
haughty stirrup
#

but cant make people change their code habits

#

to mine

#

so I will just go with theirs

somber cliff
#

Lol

#

gigachad 👈 you