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
Pretty simple solution:
chosen = playerlist[math.random( #playerlist )]