Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make it so it prints a random number from the table?

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))

1 answer

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.

2 comments

0

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.

0

Hmm strange, when I tested it. It only printed the values in the table.

This discussion is preserved as it was. New answers, comments, and votes are closed.