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
 

Re: [READ!] Forgot how to do tables :P

Previous Thread :: Next Thread 
MMOfficial is not online. MMOfficial
Joined: 20 May 2013
Total Posts: 276
08 Aug 2013 02:43 AM
It's been a long time, and I haven't scripted in a while and I forgot how to pick a random item from a table.

gm = {"Normal","Chosen"}

How do I make it choose a random gm. I forgot XD
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Aug 2013 02:44 AM
gm[math.random(1, #gm)]
Report Abuse
MMOfficial is not online. MMOfficial
Joined: 20 May 2013
Total Posts: 276
08 Aug 2013 02:45 AM
Um... I am starting to remember
Report Abuse
MMOfficial is not online. MMOfficial
Joined: 20 May 2013
Total Posts: 276
08 Aug 2013 02:46 AM
How do I make it, if it chose num1, this and that will happen, and if it chose num2, this and that will happen?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Aug 2013 02:46 AM
gm --table name
[ --indexer open
math.random( --random number method
1 --from 1
#gm --from the amount of values in gm
) --close
] --close
Report Abuse
MMOfficial is not online. MMOfficial
Joined: 20 May 2013
Total Posts: 276
08 Aug 2013 02:46 AM
Still forgeting
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Aug 2013 02:49 AM
local gm = {1, 2, "Z"}
gm[1] = 1
gm[2] = 2
gm[3] = "Z"

math.random(1, 3) = 1 or 2 or 3
#gm = 3
math.random(1, #gm) = 1 or 2 or 3
gm[math.random(1, #gm)) = 1 or 2 or "Z"
Report Abuse
MMOfficial is not online. MMOfficial
Joined: 20 May 2013
Total Posts: 276
08 Aug 2013 03:01 AM
thnx
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