Does anyone know how to make a npc move randomly from 1 part to another using pathfinding?
2 Likes
You could have a folder of possible parts the npc could move to, then randomly pick a part from the folder and have the npc compute a path to it. Once it reaches that part, you could wait a few seconds and repeat the whole process again.
1 Like
That is actually a pretty good idea, thanks!
if you need it
local Dummy = script.Parent.Dummy
local Humanoid = Dummy.Humanoid
local PartsFolder = script.Parent.Waypoints
local function MoveTo()
local RandomPart = PartsFolder:GetChildren()[math.random(1, #PartsFolder:GetChildren())]
Humanoid:MoveTo(RandomPart.Position)
Humanoid.MoveToFinished:Connect(function()
wait(3)
MoveTo()
end)
end
MoveTo()
1 Like
That made it a lot easier, thank you!
Btw quick question, Why did you add 1? what is it for?