I mean like, if I have 2 numbers I want to be randomly chosen, would it go like this?
math.random(1, 2)
I mean like, if I have 2 numbers I want to be randomly chosen, would it go like this?
math.random(1, 2)
The math.random function takes in two numbers, the minimum number, and the maximum number to compute a random number with. It returns the random number computed betwixt the two. To set two random numbers you have to use the function two different times.
local num1 = math.random(1,2)
local num2 = math.random(1,2)
Or if you have a list of values and you want to pick one randomely, I'd do
local list={a,b,c,d,e}
local random=list[math.random(1,#list)]
No, you must use a for loop to select z (for _ = 1, z do) numbers from x to y (math.random(x,y)), I will give you an example of printing 2 random numbers choosen from 1 to a million.
for _ = 1,2 do
print(math.random(1, 1000000)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Could you please re-word your question? It doesn't make any sense.