| |
|
jobro13
|
  |
| Joined: 05 Aug 2009 |
| Total Posts: 2865 |
|
| |
|
| |
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:30 PM |
You want to delete everything in workspace? local C = workspace:GetChildren() for i = 1, #C do C[i]:remove() end |
|
|
| Report Abuse |
|
|
eJorge
|
  |
| Joined: 09 Jun 2011 |
| Total Posts: 5966 |
|
|
| 25 Nov 2012 12:30 PM |
function removethosestupidparts(parent) for i,v in pairs(parent:GetChildren()) do if v:IsA("BasePart") then v:Destroy() end removethosestupidparts(v) end end removethosestupidparts(workspace) |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:31 PM |
| Like mine is so much shorter. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:31 PM |
if you're tying to get every child of workspace that's a part, use a generic for.
for i,v in pairs(workspace:GetChildren()) do if v:IsA("Part") do v:Destroy() end end
You can also add names and properties with booleans to destroy certain things. Also, things in models won't be destroyed by this. You can just destroy the model with the IsA method, or make a generic for inside your generic for for that model. |
|
|
| Report Abuse |
|
|
| |
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:32 PM |
| That's like why I removed everything |
|
|
| Report Abuse |
|
|
frost209
|
  |
| Joined: 31 Aug 2008 |
| Total Posts: 90 |
|
|
| 25 Nov 2012 12:33 PM |
this also works.
p = game.Workspace:GetChildren() for i = 1, #p do if p[i].ClassName == "Part" then p[i]:Destroy() wait() end end |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:34 PM |
| The point of the wait() being? |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:34 PM |
| Yeah, it does, but that seems pointlessly complex, correct me if there are pros to it (compared to generic for) that I do not know of. |
|
|
| Report Abuse |
|
|
eJorge
|
  |
| Joined: 09 Jun 2011 |
| Total Posts: 5966 |
|
|
| 25 Nov 2012 12:35 PM |
| Mine will remove parts inside models. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
| |
|
|
| 25 Nov 2012 12:37 PM |
| @lokkut You need a wait() in a loop, otherwise it doesn't function. Even if the safeguard is off, you add more to proccess into a frame, lengthening the frame, making lag. The lag is terrible without the safeguard if you have a giant loop for a already laggy place filled with bricks. |
|
|
| Report Abuse |
|
|
frost209
|
  |
| Joined: 31 Aug 2008 |
| Total Posts: 90 |
|
|
| 25 Nov 2012 12:38 PM |
| The Point of wait() is that it removes all the parts one by one so if there is alot of parts it wont lag. it also looks cooler while its removing it. |
|
|
| Report Abuse |
|
|
frost209
|
  |
| Joined: 31 Aug 2008 |
| Total Posts: 90 |
|
|
| 25 Nov 2012 12:38 PM |
| Also because its a loop :3 |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:40 PM |
| True, you don't need one. Seriously it at maximum is removing 30,000 things. And if you add in a wait() it'll take about 3 years. |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 25 Nov 2012 12:41 PM |
The wait() will make each part get deleted every 0.03 seconds each. 30 parts per second, instead of all parts at once (or in less than a single second, which can cause thread latency)
Also, :IsA() seems to be less efficent that simply reading the object's ClassName. This is for obvious reasons (reading is faster than running a method) |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:43 PM |
| 33* Anyway, 30 parts a second is still slow, 30000/30 = 1000 Which is over 10 mins. |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 25 Nov 2012 12:45 PM |
| I have my wait() at 0.03 seconds. You can change it in the ROBLOX Studio Settings, too. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 25 Nov 2012 12:46 PM |
| Really, never looked, only changed the amount of chat I can see to 10 really. |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 25 Nov 2012 12:47 PM |
You don't need all these random functions.. Workspace.Part:ClearAllChildren() should do it. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:47 PM |
for i, v in pairs(game.Workspace:GetChildren()) do pcall(function() v:Destroy() end) end |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 25 Nov 2012 12:48 PM |
Oh, I misread. for _,v in pairs(Workspace:GetChildren()) do if v:IsA("BasePart") then v:Destroy() end end |
|
|
| Report Abuse |
|
|