Currently, my Wander function looks something like this:
function WanderModule.Wander(Wanderer)
local newpos
local WandererHum = Wanderer:WaitForChild("Humanoid")
local HeadLoc = Wanderer.Head
local x = math.random(-100,100) -- first corner of the boundary the NPC is allowed to roam
local z = math.random(-100,100) -- the opposite corner of the boundary the NPC is allowed to roam
newpos = Vector3.new(x, HeadLoc, z)
WandererHum:MoveTo(newpos)
WandererHum.MoveToFinished:Connect(print("Moved to", newpos))
end
However, my game’s map will definitely not be a quadrilateral shape and there definitely will be walls in the way. So how would I approach this?