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: How do you select all?

Previous Thread :: Next Thread 
ibracadabra is not online. ibracadabra
Joined: 03 Nov 2010
Total Posts: 1860
25 Nov 2012 12:22 PM
[ Content Deleted ]
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
25 Nov 2012 12:25 PM
game.Selection:Get() ?
Report Abuse
ibracadabra is not online. ibracadabra
Joined: 03 Nov 2010
Total Posts: 1860
25 Nov 2012 12:28 PM
[ Content Deleted ]
Report Abuse
lokkut is not online. 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 is not online. 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 is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
25 Nov 2012 12:31 PM
Like mine is so much shorter.
Report Abuse
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
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
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
25 Nov 2012 12:32 PM
*if v:IsA("Part") then
Report Abuse
lokkut is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
25 Nov 2012 12:32 PM
That's like why I removed everything
Report Abuse
frost209 is not online. 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 is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
25 Nov 2012 12:34 PM
The point of the wait() being?
Report Abuse
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
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 is not online. eJorge
Joined: 09 Jun 2011
Total Posts: 5966
25 Nov 2012 12:35 PM
Mine will remove parts inside models.
Report Abuse
lokkut is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
25 Nov 2012 12:36 PM
Mine removes the models..
Report Abuse
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
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 is not online. 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 is not online. frost209
Joined: 31 Aug 2008
Total Posts: 90
25 Nov 2012 12:38 PM
Also because its a loop :3
Report Abuse
lokkut is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
25 Nov 2012 12:47 PM
for i, v in pairs(game.Workspace:GetChildren()) do
pcall(function()
v:Destroy()
end)
end
Report Abuse
129K is not online. 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
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