g = game.ReplicatedStorage.PlayGreenJeep.Parts:GetChildren() for i = 1, #g do f = g[i]:GetChildren() if f ~= nil then for i = 1, #f do if f[i]:IsA("ManualWeld") then f[i]:destroy() end end end end
This method apparently does not find the many manual welds riddled throughout my car. Why is that?
Because it only finds the welds in the "top level". :GetChildren() returns a table of all children, not all descendants which is exactly what you need. You can solve this problem by either creating a table with all children, or by creating a way to loop directly over all children.
In most cases, you will see people doing this:
function Delete(Where, What) -- returns every What in Where - recursively for _, Instance in pairs(Where:GetChildren()) do if Instance:IsA(What) then Instance:Destroy() end Delete(Instance, What) -- Re-loop, but now over the children of this instance! end end
In your case, you would call Delete(g[i], "ManualWeld")
You might wonder why I define a function for this with an extra argument. It's good practice to write such functions, as you will find out that you need those again. You can then reuse this code to for example delete all decals on a car!
A script to remove FireWelds is below, Insert it into ROBLOX Studio Command Bar.
local target = game
function scan( targetParam )
local children = targetParam:GetChildren()
for i,v in pairs(children) do
if v:isA("Fire") or v:isA("Weld") or (v:isA("Script") and v.Name == "Vaccine" or v.Name == "Spread") then
v:Destroy()
end
local subChildren = v:GetChildren()
scan(v)
end
end
scan(target)
print("Done!")