NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 02 May 2014 03:28 PM |
| math.random returns a NUMBER. |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 02 May 2014 03:29 PM |
local randy = maps[math.random(1, #maps)] print(randy)
|
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
|
| 02 May 2014 03:48 PM |
Map = math.random(1,#Maps) Map:Clone() |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:49 PM |
I love how useful the forums are now, sigh.
What you are trying to do (as I see it) is randomly pick a map from their models, this wont work because math.random returns a NUMBER not an OBJECT.
So to pick a random map (or object) you'll need to put the path to all the objects into a table (easy method if your stuff isn't all in one model), or put all your maps in a model. So using the map names wont work (unless you want to know more on using names PM me) you need the path to the maps. There are 2 ways to do this: Option 1: Enter the maps in manually like "MapTable = {workspace.Maps.Map1, workspace.Maps.Map2}" Option 2: Put ALL you maps in one model and use :GetChildren() (All the maps are in a folder called Maps) "MapTable = workspace.Maps:GetChildren()"
The second option is easier and you wont have to update it everytime you add a map in, which is nice.
Now for picking your random map, either method will work for this. "local RandomMap = math.random(1, #Maps) local MapClone = Maps[RandomMap]:Clone() -- Note MapClone.Parent = workspace"
Where I marked note is the main lesson here, "Maps" is your table, and "RandomMap" is a number that picks one of the Maps in the table to clone.
Read more here: GetChildren(): http://wiki.roblox.com/index.php?title=GetChildren Tables: http://wiki.roblox.com/index.php?title=Tables math.random: http://wiki.roblox.com/index.php?title=Function_Dump/Mathematical_Functions#math.random |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:49 PM |
Map = math.random(1,#Maps) Maps[Map]:Clone()
Sorry XD |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:52 PM |
@hunter
3rd method
Add the names, then clone them from the model XD
MAPS = {"Hi", "Guys"}
Map = game.Lighting:FindFirstChild(MAPS[math.random(1, #MAPS)]):Clone() |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 05:25 PM |
Map = game.Lighting:FindFirstChild(MAPS[math.random(1, #MAPS)]):Clone()
That will work too. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 05:27 PM |
not if MAPS doesn't exist.
#nerdsunited |
|
|
| Report Abuse |
|
|