How do I delete all the welds in a model?

I want to make a part fall apart when it falls onto a blade, but I cant do that without deleting all the welds. I made this script, but it doesn’t delete anything. i found out that it’s because “GetChildren” only finds the top children of the model, and not the children’s children, which I need because my model it a bunch of cubes stuck together, so it seems to fall apart. The welds are in those cubes. any help would be appreciated!

my script:

local TouchPart1 = script.Parent.Touchpart1 
local TouchPart2 = workspace.Blades
local welds = TouchPart1.Parent:GetChildren()

TouchPart1.Touched:Connect(function(Object)
	if Object == TouchPart2 then
		for i = 1, #welds do
			if welds[i]:IsA("Weld") then
				welds[i]:Destroy()
				wait(0.1)
			end
		end
	end
end)

function Touched()
	for i,v in pairs(TouchParts:GetDescendants()) do
		if v:IsA("Weld") then v:Destroy() end
	end
end

get descendants is better

2 Likes

You can also use a bit of code that I had made and was improved by our lovely friend @buildthomas