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

how to select a random name in a table?

local crime = {"Robber","Killer","None","Fighting","Spawnkilling","Sneaky","Hacking"}

local mathr = math.random(1,7)
if mathr == #crime then
	print (math.random(#crime,7))
end

Nothing outputs. Help?

1 answer

✓ Accepted answer
local crime = {"Robber","Killer","None","Fighting","Spawnkilling","Sneaky","Hacking"}

local number = math.random(1,#crime)


local chosen = crime[number]
print(chosen)

Hope this helped!

4 comments

0

You can also write >| local chosen = crime[math.random(1,#crime)]

0

Yes

0

Thanks it works.

0

Nope

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