How do I use math.random on a table?

I want to use math.random on a table of system messages to send every 250 seconds, but I don’t know how, is there a way to do this or atleast an easier way? This should be in normal lua, I don’t know why it wouldn’t be in ROBLOX lua.

local msgs = {"hi","bye","ok","nice","cool"}

local msg = math.random(0,#msgs)

print(msgs[msg])
5 Likes
local your_table = {"Hello", "Bye", "What"}

local result = your_table[math.random(1,#your_table)]
print(result)
6 Likes

wait thats a table? im so confused i thought a table was

local table = {
 "something random here idk"
}

that’s the same thing but yeah dropping it down a line just makes it easier to sort

1 Like