SetPrimaryPartCFrame, finding model top and bottom

Hey guys, I have two models, with tops and bottoms and a part in the center, how can I use SetPrimaryPartCFrame to put one of the model right under the other model?
image

local function placeUnder(m1,m2) --places m2 under m1
     m2.WorldPivot = CFrame.new(m1.OriginPosition-(Vector3.new(0,(m1:GetExtentsSize().Y/2),0)+Vector3.new(0,m2:GetExtentsSize().Y/2),0)))
end

Rough code, but you could use something like that assuming that the X and Z orientations of your models remain 0. This just adds half the first model size, and half the second model size. Then subtracts that amount from the upper blocks center. This gives the center position for the lower block.

1 Like