Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

0

This works Thanks

0

Your welcome

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.

3 comments

0

Really nice clean code! Just wanted to compliment! :-)

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

0

So i can use the mesh, but thanks for the ideas

This discussion is preserved as it was. New answers, comments, and votes are closed.