FoggedOut
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 3021 |
|
|
| 05 Aug 2013 05:19 PM |
I'm new to... Well, nothing, BUT I have forgotten a lot since I got off Roblox for a week. I need help make the table say something random each time I would run this script. If you look below, you will see the 3 Numbers I will be using, the Table{}, and the Print(). I don't know how to make the print random!
local myArray = {"1", "2", "3"} local myEmptyArray = {}
wait(5)
print(myArray[math.random]) <--- print(myArray[math.random]) <--- print(myArray[math.random]) <--- |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 05:21 PM |
You want to pick a random index, which is a number, the result of math.random:
myArray[math.random(1,#myArray)] --pick a random number from 1 to array length |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 05:22 PM |
Sooo close too1!!
math.random(min,max)
--if neither min or max is passed, it will return a float between 0 - 1
--if the max is passed, it will do 1-max
--if both are passed, it will do between min-max |
|
|
| Report Abuse |
|
|
FoggedOut
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 3021 |
|
|
| 05 Aug 2013 05:23 PM |
Oops, I probably shouldn't have put in Numbers, and a math.random to confuse people.... Here, this may help:
local myArray = {"HI THERE", "I'M IN SECOND SLOT!", "Lolwat"} local myEmptyArray = {}
wait(5)
print(myArray[math.random]) <--- print(myArray[math.random]) <--- print(myArray[math.random]) <--- |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 05:23 PM |
| Still...doesn't....change...anything.... |
|
|
| Report Abuse |
|
|