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

Question about table and picking random?

So my game will have a max amount of players of 20 and I'm creating a weather system for my game involving a storm with lightning I want the lightning to pick a random out of the 20 and zap them if all other requirements are met but I want to know if I can do something like

chosen = playerlist[math.random(1,20)]

if there's not 20 keys in the table

1 answer

✓ Accepted answer

Pretty simple solution:

chosen = playerlist[math.random( #playerlist )]

1 comment

0

ah thank you

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