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

How would i make this return a string intead of a number?

I have this code and it returns a number instead of a string.

local items = {"Murderer","Sheriff","Innocent"}
local Person1 = math.random(#items)

2 answers

✓ Accepted answer

You forgot to index your table.

Perhaps you meant items[math.random(#items)]

math.random(#items) would return a random number between 1 and 3 as the length of the table is 3. Therefore, you would have to index the table with your random number as the index.

local items = {"Murderer","Sheriff","Innocent"}
local Person1 = items[math.random(#items)]

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