So, my friend made an awesome game but the thing is, he used lots of free models and it has a lot of viruses. I was wondering if there’s a script out there that can delete all scripts in a game?
I tried use for i,v in pairs() and got the game’s descendants but I do not have the permissions I need. (I’m not sure how to use PCalls)
Just type the word “script” in the explorer search bar and then delete every script you don’t recognise.
This should get rid of any malicious code.
Hope that helped,
Theyoloman1920
You’d be better off typing “script” in the explorer search and combing through each script to ensure its meant to be there.
If you still want to proceed with deleting all scripts in the game though you can use this in the command bar:
for i,v in pairs(game:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("ModuleScript") then
v:Destroy()
end
if i%25 == 0 then
wait()
end
end
pcall(function()
for i,v in pairs(game:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("ModuleScript") then
v:Destroy()
end
if i%25 == 0 then
wait()
end
end
end)
Guess you can’t use the :GetDescendants() method on game because of a permission issue.
Try this instead:
local services = {"workspace", "ReplicatedFirst", "ReplicatedStorage", "ServerScriptService", "ServerStorage", "StarterGui", "StarterPack", "StarterPlayer", "Teams"}
for _,service in pairs(services) do
if game[service] then
for i,v in pairs(game[service]:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("ModuleScript") then
v:Destroy()
end
if i%100 == 0 then
wait()
end
end
end
end
Amazing solution, helps a lot with really bad scripts.
( Ugly but useful Necro )
if you add (game.Workspace.[Parent].[Child (if any and so on)]:GetDescendants to this, you pick a specific piece of structure to delete, really helpful when scripts have 100s of them but your game also has scripts you wish to save.
Edit: Wrong reply, oops. Still links to the original solution.
This is an old thread but hey, all the above solutions are over-complicated.
for i, v in pairs(game:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("ModuleScript") then
pcall(function()
v:Destroy()
end)
end
end
Simple, effective. No need to wait or write out certain services.
for _,v in pairs(game:GetDescendants()) do pcall(function() if v:IsA(“Script”) or v:IsA(“LocalScript”) or v:IsA(“ModuleScript”) then v:Destroy() end end) end