rny
|
  |
| Joined: 26 Jul 2009 |
| Total Posts: 5079 |
|
|
| 13 Apr 2014 06:47 PM |
| cause if i do table.insert(1, #Table_Name) it'll insert a number |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2014 06:48 PM |
| table.insert(math.random(), #Table_Name) |
|
|
| Report Abuse |
|
|
rny
|
  |
| Joined: 26 Jul 2009 |
| Total Posts: 5079 |
|
|
| 13 Apr 2014 06:53 PM |
does that get a random variable from the table |
|
|
| Report Abuse |
|
|
|
| 13 Apr 2014 07:01 PM |
Example:
--maps maps = { Bricktops Meadows Pitgrounds }
map = (math.random(1,#maps))
newMap = game.Lighting:FindFirstChild(tostring(maps[map])):Clone() newMap.Parent = workspace
This works, because you can get something inside a table using 'ExactTableName[Number]' The number indicates which variable. For example, to get Bricktops, it would be maps[1], to get meadows, maps[2], or to get pitgrounds, maps[3]. And this would go so on. You should get it now.
So math random would work. It takes the number of maps, and chooses it randomly. Then, since you can use maps[number] to get the variable, it does this: maps[RandomNumberHereFrom1ThroughHowManyVariables]
This would do this exactly:
>Choose a random map (Even though it isn't a TRUE random number generator) >And parent it to workspace (This would only work if it is the EXACT name of a map in lighting, but string.lower can be used)
And tostring is required, because the variables aren't strings.
Sorry for any bad explanations, etc. This is just how I see it. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 13 Apr 2014 07:07 PM |
Lol he's asking for this..
Table = { variable1 variable2 variable3 }
Picked_Variable = (Table[math.random(1,#Table)])
print(Picked_Variable)
You use the math.random method on the statistics of a table. |
|
|
| Report Abuse |
|
|
rny
|
  |
| Joined: 26 Jul 2009 |
| Total Posts: 5079 |
|
|
| 17 Apr 2014 02:31 PM |
i just winged it and did this
local Number = math.random(1,#Spectators);local Add = Spectators[Number] table.insert(Hit_Men, Add);table.remove(Spectators, Number) |
|
|
| Report Abuse |
|
|