I'm trying to remove all my scripts in my game. The issue is that there are so many I'm wondering if I could run a command to delete the scripts in studio using Run a command??
hi, its not the easiest thing just put this in the command bar.
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 i0 == 0 then wait() end end end end
I tested this it works.
There Isn't really a command for it but you could loop through game
and check if any of the descendants are scripts. Tho it isn't a very good idea because you will also destroy scripts created by roblox that are necessary to run the game.
here's my idea:
for i, v in pairs(game:GetDescendants()) do -- getting EVERYTHING in the game if v:IsA("Script") then -- checking if one of that everything is a script v:Destory() -- Destroying the scripts end end
if you want to destroy scripts that are created by you then ive got a simple solution. Just insert a value inside of your script, name your value to something you want and then check if the script has the value with the right name inside it
Example:
for i, v in pairs(game:GetDescendants()) do if v:IsA("Script") then if v:FindFirstChild("YourValuesName") then -- here we are checking for the value v:Destroy() end end end
tho it isnt the best solution because active loops that are running inside of scripts wont stop/break if the script gets destroyed/deleted. first you would need to somehow stop the loops (if you have any) by using break
.
Maybe you could use a function called "script.destroying" and then break the loop. (.destroying basically checks if something is getting destroyed)
Please note that i havent checked if any of the scripts above are working correctly.