PivotTo only moving PrimaryPart

I’m making a system for loading the player’s base from being serialized into a dictionary. While trying to recreate the models in the correct position I found that only the model’s primary part is being moved with :PivotTo. The CFrame of the primary part itself is entirely correct.

function module.Deserialize(t)
	if not t then return nil end
	
	local base = game:GetService("ServerStorage").Base:Clone()
	
	for modelName: string, instances in t do
		for _, data in instances do
			local model: Model = RS.BuildingParts:FindFirstChild(modelName, true):Clone()
			model.Parent = base.BuildArea
			
			model.PrimaryPart:PivotTo(CFrame.new(unpack(data.CFrame)))
		end
	end
	
	return base
end

I’ve never had this happen before so I’m unsure what to do about it. I’ve already checked that all children are being loaded and tried putting a task.wait(1) before using :PivotTo but to no avail. Actually pivoting the model using the command bar works fine.

I’ve found that adding all models and their desired CFrame to another array and then going through that and pivoting them works as a solution. I’m still curious as to why it just doesn’t work with the code in my first post.

That’s because you’re calling PivotTo() on the PrimaryPart, which will only transform it, and descendant PVInstances.

Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame. This is the primary function that should be used to move Models via scripting.

You should call it on the model itself.

What he said - Model:PivotTo()

Yeah, I figured it was something stupid haha. Thank you for enlightening me, it seems like I could use some sleep.