local G={}table.insert(G,mainPart)function Weld(v,S)weld=Instance.new("\087\101\108\100")weld.Part0=v weld.Part1=S local d=CFrame.new(v.Position)weld.C0=v.CFrame:inverse()*d weld.C1=S.CFrame:inverse()*d weld.Parent=v table.insert(G,S)end function WeldRec(G)local v=G:GetChildren()for G,v in pairs(v)do if v:IsA("\077\101\115\104\080\097\114\116")then Weld(mainPart,v)end WeldRec(v)end end WeldRec(P)

local weldedParts = {}
table.insert(weldedParts,mainPart)

function Weld(x, y)
	weld = Instance.new("Weld") 
	weld.Part0 = x
	weld.Part1 = y
	local CJ = CFrame.new(x.Position) 
	weld.C0 = x.CFrame:inverse() * CJ  
	weld.C1 = y.CFrame:inverse() * CJ  
	weld.Parent = x	
	table.insert(weldedParts,y)
end

function WeldRec(instance)
	local childs = instance:GetChildren()
	for _,v in pairs(childs) do
		if v:IsA("MeshPart") then
			Weld(mainPart, v)
		end
		WeldRec(v)
	end	
end

WeldRec(P)