How to use pathfinding to make an npc move around without waypoints?

Hello. How can I make an npc move around, but not use any parts? I just want to to move around the map randomly.

Generate a random position to pathfind to.

function generateRandomDestination(char)
	local hrp = char.PrimaryPart or char:FindFirstChild("HumanoidRootPart");
	local randomPos = hrp.Position + Vector3.new(math.random(-50, 50), 0, math.random(-50, 50));
	
	return randomPos;
end

This will generate a random position within 50 studs of the given character.

1 Like