Destroy welds with part

I have this script inside of a part because I want this part to destroy welds of other parts in models in workspace when it comes into contact with them, however it’s not working.

script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild(“Humanoid”)
if humanoid ~= nil then
return
else
local all = hit:FindFirstChildOfClass(“Weld”) or hit.Parent:FindFirstChildOfClass(“Weld”)
repeat
all = hit:FindFirstChildOfClass(“Weld”) or hit.Parent:FindFirstChildOfClass(“Weld”)
if all then
all:Destroy()
end
until all == nil
end
end)

2 Likes

Search the descendants of hit.Parent and destroy the weld

for I, v in pairs(Hit.Parent:GetDescendants()) do
If v:IsA(“Weld”) then
v:Destroy()
end
end

1 Like

Refer to this?

2 Likes

Read @JackscarIitt comment

Maybe this is what you are looking for?

Thought you wanted to find a weld in a part and destroy it, not all welds Idk