How to use PathFindingService for Randomly moving NPC?

I want to make an NPC move randomly with PathFindingService and waypoints so that it will move around objects and jump over them as well. Right now I do have a script but it will just move in random directions and run into things.

I want a smart system to make the NPC run around but at the same time, I don’t have a set point for it to move to because I want it to be a random movement.

Current Script:

while true do
	local randomlocation = npc.PrimaryPart.Position + Vector3.new(math.random(-50,50), 0, math.random(-50,50))
		
	npc.Humanoid:MoveTo(randomlocation)
	npc.Humanoid.MoveToFinished:Wait()
end
1 Like