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: Is there a way that I can select a random part in a model?

Previous Thread :: Next Thread 
Oaktin is not online. Oaktin
Joined: 01 Sep 2013
Total Posts: 119
13 Oct 2014 05:30 AM
If I have a model that has 100 Parts in it and I want it to select a random part until there is nothing left in the model. (i can make them remove) Please Help Thanks!
Report Abuse
Syrt is not online. Syrt
Joined: 30 Sep 2011
Total Posts: 2745
13 Oct 2014 06:14 AM
Right Click > Select Children > Delete

"We only want more freedom or independence because we see other people with more than us."
Report Abuse
Fakecake777 is not online. Fakecake777
Joined: 19 Nov 2012
Total Posts: 441
13 Oct 2014 07:49 AM
local model = yourModelHere

for i = 1, #model:GetChildren() do
model:GetChildren()[math.random(1,#model:GetChildren())]:Destroy()
wait(0.2)
end

this will remove every thing in your model, one at a time, randomly selected.
Report Abuse
ClimaxDarkness is not online. ClimaxDarkness
Joined: 26 Nov 2009
Total Posts: 19
14 Oct 2014 10:16 AM
The above solution does work- but each time you MUST delete the brick in order to randomly select a different one from the remaining parts. This script allows a much more controlled way of doing so:

local m = workspace.Model -- replace this with your model
local parts = m:GetChildren()
for i=1, #parts, 1 do
local n = math.random(1,#parts)
local part = parts[n]
table.remove(parts,n) -- doesn't destroy the brick, but removes it from the data still waiting to be used
--do the method here on variable "part", e.g. part:Destroy()
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