|
| 18 Apr 2016 07:09 PM |
| I have a table for example: List = {9,91,3,23,40} How would i print a random number out of the table given? |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 18 Apr 2016 07:15 PM |
| print(List[math.random(#List)]) |
|
|
| Report Abuse |
|
|
Lecturous
|
  |
| Joined: 17 Aug 2013 |
| Total Posts: 1096 |
|
|
| 18 Apr 2016 07:17 PM |
print(List[math.random(1, #List)])
Explanation: You can get values out of arrays by using an index, like this: List[1] -- it would get the first value out of the table
So we can use a random number between 1 and the total amount of values in the array as an index. List[math.random(1, #List)] |
|
|
| Report Abuse |
|
|