Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there away to run a command in studio to remove scripts all at once??

Asked by 1 year ago

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??

2 answers

Log in to vote
2
Answered by 1 year ago

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.

0
This works Thanks theking66hayday 841 — 1y
0
Your welcome 666_brithday 103 — 1y
Ad
Log in to vote
2
Answered by
Klui36 45
1 year ago

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.

0
Really nice clean code! Just wanted to compliment! :-) KarateKid147 4 — 1y
0
What I am kinda doing is I have separate games ones with models and the other with my code. The one with models I just want to clear all the code off theking66hayday 841 — 1y
0
So i can use the mesh, but thanks for the ideas theking66hayday 841 — 1y

Answer this question