Deleting all scripts from game?

I made a script based on GetDescendants that (should) remove EVERY script in the game, but for some reason I don’t think it’s working as some GUI functions still work.

Here is the script I am using.

for i, v in pairs(workspace:GetDescendants()) do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
	end
2 Likes
for i, v in pairs(workspace:GetDescendants()) do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
	end

you forgot to put “)” in the last end

for i, v in pairs(workspace:GetDescendants()) do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
end)
1 Like

You are only checking inside the workspace? Is this by choice?

1 Like

No I want the whole game… Did I forget that…?

and you should remove the last )

for i, v in pairs(workspace:GetDescendants() do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
end)

guess it works now

If you want to delete scripts from the entire game I think it should be

for i, v in pairs(game:GetDescendants() do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
	end
1 Like
for i, v in pairs(game:GetDescendants() do
	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript")then
			v:Destroy()
		end
	end)

I’m getting syntax errors with that script you sent…

Sorry, I made a mistake. It should be good now.

for i, v in pairs(game:GetDescendants()) do
    	if v:IsA("Script") or v:IsA("ModuleScript") or v:IsA("ScriptService") or v:IsA("BaseScript") or v:IsA("CoreScript") or v:IsA("LocalScript") then
    			v:Destroy()
    	end
end
2 Likes

I don’t believe you can delete core scripts, and there are some modules and such in CoreGui and a few other services, your modules and other scripts should usually only be in workspace, replicated first/storage, server script service, and starter player.

So I recommend selecting them all in the explorer and just in general anywhere else where there might be scripts then doing the following in the console.

for _, service in ipairs(game:GetService("Selection"):Get()) do
    for _, descendant in ipairs(service:GetDescendants()) do
        if descendant:IsA("LuaSourceContainer") then
            descendant:Destroy()
        end
    end
end

ModuleScripts, CoreScripts (but you shouldn’t have any of those in workspace, server script service, etc), LocalScripts, and Scripts, all inherit from the LuaSourceContainer class, so instead of manually checking all 4 (:IsA takes into account inheritance! Use that to your advantage!) just check a class they inherit from.

“ScriptService” is an actual service, not any actual Script class.

3 Likes

Put it in StarterPlayerScripts.

1 Like

May I ask why you need to remove every script from the game in the first place?

1 Like

I just wondering what it would be like playing Roblox with no scripts!