I would like to make something where I could set up a set of values like
local numbers = {"1", "2",} --etc. local pickednumber = numbers[math.random(1, #numbers)]
But I want to make it so I don't have to list every number to be able to pick from it.
If you have further questions or can help it would be appreciated :)
So, you want to randomly select a number, from a range of numbers that you specify?
You're really over-analyzing this, all you have to do is use the math.random
function, with the second argument set as your range.
local range = 100 --Define your range local number = math.random(1,range) --Random number between 1 and 'range'
I'm not quite sure what your main goal is. But if you are looking to pick a random number here. This is on a loop, so fix it accordingly to what you would like it to be. Also note that the wait(1)
is optional, so if you want the numbers to load slower, use it.
Code:
local numbers = {"0",} for i = 1, 100 do --wait(1) table.insert(numbers,(i)) end while wait(1) do local pickednumber = numbers[math.random(1, #numbers)] print(pickednumber) end
Hope this helped!