How to remove every single script found by find results

I have scripts that I don’t need anymore in my game and I think it’s causing lag. I don’t want to delete 900 scripts by hand. It won’t let me select everything it found and delete all of them. Is there an easier way to do this?

1 Like

Use the command bar with the following command (ensure you place the name of the script in the command):

local ScriptName = --put the name of the script here

for _, Des in ipairs(game:GetDescendants()) do
    if Des:IsA("BaseScript") and Des.Name == ScriptName then
        Des:Destroy()
    end 
end

The problem is that uh, the scripts name is called “script” so that would remove every script in the game

Do you scripts want to remove have the same exact content?

Yes. They do.-----------------

Ok then do this:

local SourceCode = [[Copy the code from one of the scripts and place here]]
local services = {
	game.Workspace,
	game:GetService("ReplicatedFirst"),
	game:GetService("ReplicatedStorage"),
	game:GetService("ServerScriptService"),
	game:GetService("ServerStorage"),
	game:GetService("StarterGui"),
	game:GetService("StarterPlayer"),
	game:GetService("Lighting")
}

function GetAllScripts()
	local scripts = {}
	for _,service in pairs(services) do
		for _,child in pairs(service:GetDescendants()) do
			if (child:IsA("LuaSourceContainer")) then
				scripts[#scripts + 1] = child
			end
		end
	end
	return scripts
end

for _, Script in pairs(GetAllScripts()) do
	if (string.find(Script.Source, SourceCode)) then
		Script:Destroy()
	end
end
1 Like

Thank you.--------------------