How do you make it so it prints a random number from the table? It cannot choose the numbers that are not listed on the table. Thanks!
local value = {1, 3, 7, 10, 12, 13}
print(math.random(value))
How do you make it so it prints a random number from the table? It cannot choose the numbers that are not listed on the table. Thanks!
local value = {1, 3, 7, 10, 12, 13}
print(math.random(value))
Hi there, this is actually quite simple. You almost got there but hopefully this script should help:
local value = {1, 3, 7, 10, 12, 13} -- These are inside of your table
local rad = math.random(1, #value)
print(value[rad])
Hopefully I could help, enjoy your day.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Thank you for answering, but I tested it, and it picks a number that is not in the table. The #value gets replaced with the number of values in the table, so it is like math.random(1, 6) since there are 6 numbers in the table.
Hmm strange, when I tested it. It only printed the values in the table.