local p=Random.new(tick())return function(E,u)local z local a=E.CFrame.Position while not z do local X,F=(a.X-E.Size.X/2)+u.X,(a.X+E.Size.X/2)-u.X local Q,k=(a.Y-E.Size.Y/2)+u.Y,(a.Y+E.Size.Y/2)-u.Y local e,h=(a.Z-E.Size.Z/2)+u.Z,(a.Z+E.Size.Z/2)-u.Z local i,B,v=p:NextNumber(X,F),p:NextNumber(Q,k),p:NextNumber(e,h)local U,o=Vector3.new(i,B,v)+u,Vector3.new(i,B,v)-u local q=Region3.new(U,o)local y=workspace:FindPartsInRegion3(q,nil,1)if#y==0 then z=Vector3.new(i,B,v)end wait()end return z end
--[[
	Returns a random vector3 within a region3, that has a clear area around it of specified size. This function yields.
]]
local random = Random.new(tick())

return function(region, clearAreaSize)
	local position

	local regionPosition = region.CFrame.Position

	while not position do
		local minX, maxX =
			regionPosition.X - (region.Size.X / 2) + clearAreaSize.X,
			regionPosition.X + (region.Size.X / 2) - clearAreaSize.X
		local minY, maxY =
			regionPosition.Y - (region.Size.Y / 2) + clearAreaSize.Y,
			regionPosition.Y + (region.Size.Y / 2) - clearAreaSize.Y
		local minZ, maxZ =
			regionPosition.Z - (region.Size.Z / 2) + clearAreaSize.Z,
			regionPosition.Z + (region.Size.Z / 2) - clearAreaSize.Z

		local x, y, z = random:NextNumber(minX, maxX), random:NextNumber(minY, maxY), random:NextNumber(minZ, maxZ)

		local clearRegionMax, clearRegionMin =
			Vector3.new(x, y, z) + clearAreaSize, Vector3.new(x, y, z) - clearAreaSize

		local area = Region3.new(clearRegionMax, clearRegionMin)

		local partsInArea = workspace:FindPartsInRegion3(area, nil, 1)

		if #partsInArea == 0 then
			position = Vector3.new(x, y, z)
		end
		wait()
	end

	return position
end
