I have a script that welds a group of blocks in a model to its primary part in place. When they are not anchored, all the parts are not welded in their place, instead, they all teleport to the position of the primary part and is welded at that position.

What I mean:

Unwelded Island and Welding when not anchored: https://imgur.com/a/s2xqiE3

Code snippet:

Gui has a button that once clicked will get the model from the textbox, then finds the primary part, then uses the applyOnChildren method to call the weldToPrimaryPart function between each part and the primary part.

function applyOnChildren(p, f, args)
	print(12)
	local children = p:getChildren()
	for index = 1, #children do
		f(children[index],args)
	end
end

function weldToPrimaryPart(part,primary)
	print(20)
	local w = Instance.new("ManualWeld") 
	w.Parent = primary
	w.Part0 = primary
	w.Part1 = part 
	w.C0 = primary.CFrame:inverse() * part.CFrame
	print(w.C0)
end

function weld(model)
	print(27)
	applyOnChildren(model,weldToPrimaryPart,model.PrimaryPart)
end

function onClick()
	print(31)
	local modelName = gui.WeldFrame.ModelName.Text
	print(modelName)
	if not (isempty(modelName)) then
		print(34)
		local model = workspace:FindFirstChild(modelName)
		if model~= nil then
			weld(model)
		end
	end
end