Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

FindFirstChild through every descendant?

What I am trying to do, since I accidentally installed an infected plugin, remove all the scripts it added.

As it was put into every model in the place, duplicated infinitely, I was wondering how I would make this search through every descendant of every descendant.

A = game.Workspace:GetChildren()

for i,v in pairs(A) do
    if v.ClassName == "Script" then
		if v:FindFirstChild("4D Being") then
			v:remove()
		end
    end
end

1 answer

✓ Accepted answer

Easy, use a Changed event, it will clean, but not any new elements.

A = game.Workspace:GetChildren()


game.Workspace.Changed:connect(function()
    for i,v in pairs(A) do
        if v.ClassName == "Script" then
            if v:FindFirstChild("4D Being") then
                v:remove()
           end
        end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.