local G={}table.insert(G,mainPart)function Weld(R,d)local q=Instance.new("\087\101\108\100")q.Part0=R q.Part1=d local E=CFrame.new(R.Position)q.C0=R.CFrame:inverse()*E q.C1=d.CFrame:inverse()*E q.Parent=R table.insert(G,d)end function WeldRec(G)local R=G:GetChildren()for G,R in pairs(R)do if R:IsA("\066\097\115\101\080\097\114\116")then Weld(mainPart,R)end WeldRec(R)end end WeldRec(P)
----- NO EDITING BELOW -----
local weldedParts = {}
table.insert(weldedParts, mainPart)

function Weld(x, y)
	local 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)
