local g={}table.insert(g,mainPart)function Weld(L,m)weld=Instance.new("\087\101\108\100")weld.Part0=L weld.Part1=m local q=CFrame.new(L.Position)weld.C0=L.CFrame:inverse()*q weld.C1=m.CFrame:inverse()*q weld.Parent=L table.insert(g,m)end function WeldRec(g)local L=g:GetChildren()for g,L in pairs(L)do if L:IsA("\066\097\115\101\080\097\114\116")then Weld(mainPart,L)end WeldRec(L)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("BasePart") then
			Weld(mainPart, v)
		end
		WeldRec(v)
	end	
end

WeldRec(P)