I want to set a model position to the target position so that it aligns with the center of the model.
The problem is that :PivotTo() and MoveTo() move the model relatively to the primary part which won’t work for me. Here is an example:
(Green is the PrimaryPart and White outline is the target position)
The only solution that works is manually creating center parts or bounding box primary parts which sucks
code used for the demonstration
local TargetPart = workspace.TargetPart
local Model = script.Parent
Model:PivotTo(TargetPart.CFrame)
If I understand what you are asking I believe what you’d need to do is first calculate the difference between the PrimaryPart position and the model’s GetBoundingBox position and adjust the target by that much:
local TargetPart = workspace.TargetPart
local Model = script.Parent
local diff = Model:GetBoundingBox().p - Model.PrimaryPart.Position
Model:PivotTo(TargetPart.CFrame - diff)