I was just testing some stuff for a project and I got confused with randomly printing strings. The problem that I get is that it is printing its table value/order (Ie. [1], [2] etc) How would I make it print the string
local test = { "Test1", "Test2" "Test3" } local random = math.random(1, #strings) print(random)
You are very close! First thing, you messed up your table. You have to put a comma after each index, and you forgot one after the 2nd. Secondly, when trying to get a random value from a table, you have to first index the table!
local test = {"Test1","Test2","Test3"} local random = test[math.random(#test)] -- The # operator represents how many INDEXES (values) are inside the table!. print(random)