generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What's a script to remove all scripts in workspace?

Previous Thread :: Next Thread 
TheDarkMelon is not online. TheDarkMelon
Joined: 26 Jan 2013
Total Posts: 17713
28 Oct 2013 07:46 AM
[ Content Deleted ]
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 08:07 AM
x = game.Workspace:GetChildren()

If x.className == "Script" then

x:remove()
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
28 Oct 2013 08:15 AM
^ Wtf?

for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA('Script') then
v:Destroy()
end
end
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 09:21 AM
Mine works for me you just loop remove them.
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 10:19 AM
@CustardCream95
Then why did you not loop it in your example?

@OP
Here's an example that will go within every object inside of Workspace too:

function rec(v)
for i, v in pairs(v:GetChildren()) do
if (v.ClassName == "Script" or v.ClassName == "LocalScript") then
v:Destroy()
else
rec(v)
end
end
rec(game.Workspace)

This is my siggy when I'm at school c:
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 10:32 AM
Because he never said to continuously remove scripts so I posted a simple script that would remove all current scripts in the Workspace(Not in anything just loos).
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
28 Oct 2013 10:37 AM
^ You're doing it wrong...?

for _,v in pairs(game.Workspace:GetChildren()) do
If v:IsA'BaseScript' then
v:destroy()
end
end
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 10:37 AM
No you didn't let me explain:

x = game.Workspace:GetChildren() -- This gives you a table

If x.className == "Script" then -- A table does not have a className. Unless, of course, you have an index in it named "className". However, I am going to assume that you do not.

x:remove() -- There is no method "remove" in tables either. You can set the table to nil to erase it from the system's memory during the next garbage collection, but there is no "remove" method in them.

Now let me show you how you could make your script work:

x = game.Workspace:GetChildren()
for i = 1, #x do -- Make "i" 1, and add 1 to it until it's equal to "#x", or the length of "x"
if (x[i].ClassName == "Script") then -- If the index of the table of "i" (which would be an Object) is a Script, then
x:Destroy() -- Destroy is better than remove
end
end

This is my siggy when I'm at school c:
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 10:39 AM
-.- People at LuaLearners tell me I am right though D: Gah I'm so lost now. MY WHOLE SCRIPTING LIFE ~HAS BEEN A LIE D:
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 10:41 AM
It's no problem. Here are a few pages that should help you get on track:
http://wiki.roblox.com/index.php/Table
http://wiki.roblox.com/index.php/Loops

This is my siggy when I'm at school c:
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image