|
| 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 |
|
|
|
| 01 Mar 2015 11:19 AM |
| Table[math.random(1, #Table)] |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2015 11:41 AM |
| wait there is a problem it's only giving me #3 |
|
|
| Report Abuse |
|
|
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 |
|
|