local function y(y,w)return{y:PointToWorldSpace(Vector3.new(-w.x,w.y,w.z));y:PointToWorldSpace(Vector3.new(-w.x,-w.y,w.z)),y:PointToWorldSpace(Vector3.new(-w.x,-w.y,-w.z)),y:PointToWorldSpace(Vector3.new(w.x,-w.y,-w.z)),y:PointToWorldSpace(Vector3.new(w.x,w.y,-w.z));y:PointToWorldSpace(Vector3.new(w.x,w.y,w.z));y:PointToWorldSpace(Vector3.new(w.x,-w.y,w.z));y:PointToWorldSpace(Vector3.new(-w.x,w.y,-w.z))}end local function w(y)local w,s,X={},{},{}for H=1,#y,1 do w[H],s[H],X[H]=y[H].x,y[H].y,y[H].z end local H=Vector3.new(math.min(unpack(w)),math.min(unpack(s)),math.min(unpack(X)))local K=Vector3.new(math.max(unpack(w)),math.max(unpack(s)),math.max(unpack(X)))return H,K end


local function getCorners(cf, s2)
	return {
		cf:PointToWorldSpace(Vector3.new(-s2.x, s2.y, s2.z));
		cf:PointToWorldSpace(Vector3.new(-s2.x, -s2.y, s2.z));
		cf:PointToWorldSpace(Vector3.new(-s2.x, -s2.y, -s2.z));
		cf:PointToWorldSpace(Vector3.new(s2.x, -s2.y, -s2.z));
		cf:PointToWorldSpace(Vector3.new(s2.x, s2.y, -s2.z));
		cf:PointToWorldSpace(Vector3.new(s2.x, s2.y, s2.z));
		cf:PointToWorldSpace(Vector3.new(s2.x, -s2.y, s2.z));
		cf:PointToWorldSpace(Vector3.new(-s2.x, s2.y, -s2.z));
	}
end

local function worldBoundingBox(set)
	local x, y, z = {}, {}, {}
	for i = 1, #set do x[i], y[i], z[i] = set[i].x, set[i].y, set[i].z end
	local min = Vector3.new(math.min(unpack(x)), math.min(unpack(y)), math.min(unpack(z)))
	local max = Vector3.new(math.max(unpack(x)), math.max(unpack(y)), math.max(unpack(z)))
	return min, max
end
