| |
|
|
| 28 Oct 2013 08:07 AM |
x = game.Workspace:GetChildren()
If x.className == "Script" then
x:remove() |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 28 Oct 2013 09:21 AM |
| Mine works for me you just loop remove them. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|