Context: This is a part in a part being used in a viewport frame. The parent is being adjusted to create a good view for the viewportframe, but the child is left behind and can’t be seen (or is incorrectly positioned)
Code:
local viewportItem = child.Handle:Clone()
local ogFrame = viewportItem.CFrame
viewportItem.CFrame = CFrame.new() * viewportItem.ViewportOffset.Value
for _, otherPart: BasePart in pairs(viewportItem:GetChildren()) do
if otherPart:IsA("BasePart") == false then
continue
end
otherPart.CFrame = ogFrame:ToObjectSpace(otherPart.CFrame) * viewportItem.CFrame -- * viewportItem.ViewportOffset.Value
end
I have no doubt this would work but this isn’t the solution I was looking for. I want to calculate the position relative to the first part as it is a learning experience and can possibly save time. I am not using a model because the original form was a tool instance which I find excessive to create a model with automated pivot.