local D=Random.new(tick())return function(Y,n)local g local u=Y.CFrame.Position while not g do local T,Q=(u.X-Y.Size.X/2)+n.X,(u.X+Y.Size.X/2)-n.X local z,N=(u.Y-Y.Size.Y/2)+n.Y,(u.Y+Y.Size.Y/2)-n.Y local M,t=(u.Z-Y.Size.Z/2)+n.Z,(u.Z+Y.Size.Z/2)-n.Z local F,I,m=D:NextNumber(T,Q),D:NextNumber(z,N),D:NextNumber(M,t)local B,P=Vector3.new(F,I,m)+n,Vector3.new(F,I,m)-n local l=Region3.new(B,P)local G=workspace:FindPartsInRegion3(l,nil,1)if#G==0 then g=Vector3.new(F,I,m)end wait()end return g end

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
