local function P(P)local l=randomGenerator:NextInteger(-P.Size.X/2,P.Size.X/2)local r=randomGenerator:NextInteger(-P.Size.Y/2,P.Size.Y/2)local O=randomGenerator:NextInteger(-P.Size.Z/2,P.Size.Z/2)local v=Vector3.new(l,r,O)local S=P.CFrame:pointToWorldSpace(v)local z=math.pi*2 local x=randomGenerator:NextNumber()*z local A=randomGenerator:NextNumber()*z local U=randomGenerator:NextNumber()*z local k=CFrame.Angles(x,A,U)k=k+S return k end
-- Finds a random position inside of the given part and returns a randomly rotated CFrame at that position
local function getRandomCFrameInVolume(partVolume)
	-- Calculate the position component of the random CFrame
	local x = randomGenerator:NextInteger(-partVolume.Size.X / 2, partVolume.Size.X / 2)
	local y = randomGenerator:NextInteger(-partVolume.Size.Y / 2, partVolume.Size.Y / 2)
	local z = randomGenerator:NextInteger(-partVolume.Size.Z / 2, partVolume.Size.Z / 2)
	local localOffset = Vector3.new(x, y, z)
	local worldOffset = partVolume.CFrame:pointToWorldSpace(localOffset)

	-- Calculate the rotation component of the random CFrame
	local twoPi = math.pi * 2
	local xRotation = randomGenerator:NextNumber() * twoPi
	local yRotation = randomGenerator:NextNumber() * twoPi
	local zRotation = randomGenerator:NextNumber() * twoPi
	local CFrame = CFrame.Angles(xRotation, yRotation, zRotation)

	-- Add the position and rotation together to get the full random CFrame
	CFrame = CFrame + worldOffset

	return CFrame
end
