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 » Scripters
Home Search
 

Re: How do you get random member of a table?

Previous Thread :: Next Thread 
extremeninjamaster is not online. extremeninjamaster
Joined: 25 Feb 2012
Total Posts: 2570
01 Mar 2015 11:17 AM
Hey guys. Is there any way to get a random value in a table? For example...

Table = {1, 2, 3}

I want it to randomly print the numbers 1, 2, or 3.

Is there any way to do this?
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
01 Mar 2015 11:19 AM
Table[math.random(1, #Table)]
Report Abuse
extremeninjamaster is not online. extremeninjamaster
Joined: 25 Feb 2012
Total Posts: 2570
01 Mar 2015 11:22 AM
Wow thanks bro :D
Report Abuse
extremeninjamaster is not online. extremeninjamaster
Joined: 25 Feb 2012
Total Posts: 2570
01 Mar 2015 11:41 AM
wait there is a problem it's only giving me #3
Report Abuse
vydlv is not online. vydlv
Joined: 08 Jun 2010
Total Posts: 1517
01 Mar 2015 12:15 PM
idk why you're getting 3

tbl = {1, 2, 3,4}
print(tbl[math.random(1,#tbl)])

should work
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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