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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
02 May 2014 03:01 PM
[ Content Deleted ]
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
02 May 2014 03:02 PM
math.random(#maps)?
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
02 May 2014 03:09 PM
[ Content Deleted ]
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
02 May 2014 03:23 PM
[ Content Deleted ]
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
02 May 2014 03:27 PM
[ Content Deleted ]
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
02 May 2014 03:28 PM
math.random returns a NUMBER.
Report Abuse
Azarth is not online. 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 is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
02 May 2014 03:31 PM
[ Content Deleted ]
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
02 May 2014 03:48 PM
Map = math.random(1,#Maps)
Map:Clone()
Report Abuse
HunterCop224 is not online. HunterCop224
Joined: 17 Aug 2009
Total Posts: 112
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
02 May 2014 03:49 PM
Map = math.random(1,#Maps)
Maps[Map]:Clone()



Sorry XD
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
HunterCop224 is not online. HunterCop224
Joined: 17 Aug 2009
Total Posts: 112
02 May 2014 05:25 PM
Map = game.Lighting:FindFirstChild(MAPS[math.random(1, #MAPS)]):Clone()

That will work too.
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
02 May 2014 05:27 PM
not if MAPS doesn't exist.

#nerdsunited
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