[REPOSTED] Choose Random Position Inside A Part

I know that math.random(-xsize/2,xsize/2),math.random(-ysize/2,ysize/2),math.random(-zsize/2,zsize/2) works but, thats only if the part is 0,0,0 rotation, when i rotate the part, the random points makes it that the part is still acting like the 0,0,0 rotation, idk if u get what i mean but basically when i rotate the big part that items are suppose to spawn randomly inside it, the items still spawn randomly like the big part is not rotated

Setting the parts CFrame instead of the Position should work.

local PartA = workspace.PartA
local PartB = workspace.PartB

local RandomPos = Vector3.new(math.random(-PartB.Size.X/2,PartB.Size.X/2), math.random(-PartB.Size.Y/2,PartB.Size.Y/2), math.random(-PartB.Size.Z/2,PartB.Size.Z/2))

PartA.CFrame = PartB.CFrame + RandomPos