|
| 12 Apr 2012 06:51 AM |
How would you make it so that it picks out a random child out of a model? EG. I have 5 maps in a model that is in lighting. It goes like this: Lighting>Maps> All the maps. How would you make it so that it picks out one of the maps randomly and puts it into workspace? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 12 Apr 2012 06:53 AM |
| local rChild = Game.Lighting.Map:GetChildren()[math.random(1, #game.Lighting.Map:GetChildren()] |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 12 Apr 2012 06:54 AM |
maps = game.Lighting:GetChildren()
and than something like this
map = math.random(1, maps)
I just forgot it. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 12 Apr 2012 06:55 AM |
Well take MrNicNacs script just with an s at the end of Map like this:
local rChild = Game.Lighting.Maps:GetChildren()[math.random(1, #game.Lighting.Maps:GetChildren()] |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 07:20 AM |
Like MrNicNac said, but if you are using a function to pick a random map, and then indexing the map outside that function you will have to remove the "local".
~ Men are like Bank accounts. Without a lot of money they don’t generate a lot of interest. ~ |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 07:22 AM |
| Sorry, but i didn't get one word of that. Would the script Cheater gave me work? |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 12 Apr 2012 07:23 AM |
| Ya, MrNicNac wrote "Map" instead of "Maps". And you said the directory is called "Maps". |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 09:24 AM |
Btw i forgot to say. Once it's picked a random map how would you make it so it puts ONLY THAT MAP in workspace? And renames the map... |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 12 Apr 2012 09:29 AM |
>local rChild = Game.Lighting.Map:GetChildren()[math.random(1, #game.Lighting.Map:GetChildren()]
Why not just save the table with children as local variable instead of calling the method twice? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 09:32 AM |
| As usual su8 was no help at all.... |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 12 Apr 2012 09:37 AM |
>As usual su8 was no help at all....
My post wasn't pointed to you.. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 09:43 AM |
MODEL=??? a=MODEL:GetChildren()[math.random(#MODEL:GetChildren())] |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 10:35 AM |
| I got the random selection robert,but how do you put that map that was selected into workspace? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 10:37 AM |
a.Parent=workspace a:MakeJoints() |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 10:39 AM |
a=game.Lighting.Maps:GetChildren()[math.random(#game.Lighting.Maps:GetChildren())] a.Parent.workspace a:MakeJoints() |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Apr 2012 10:56 AM |
Lol wow, I messed that up...
a=game.Lighting.Maps:GetChildren()[math.random(#game.Lighting.Maps:GetChildren())] a.Parent=workspace a:MakeJoints() |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 11:04 AM |
| Can i ask what the make joints is for? |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 12 Apr 2012 11:08 AM |
| It's just so it wont fall apart |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 11:13 AM |
| If the model we are moving out of lighting and into workspace has any joints in it, in other words, parts that are together without the parts being anchored, then the model will fall apart without that simple bit of code. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2012 11:13 AM |
MakeJoints() method does exactly as it says on the tin.
http://wiki.roblox.com/index.php/MakeJoints_(Method)
~ Men are like Bank accounts. Without a lot of money they don’t generate a lot of interest. ~ |
|
|
| Report Abuse |
|
|