PLEASE HELP!
math.randomseed(tick())
playerTbl = {}
plnum = 0
game.Players.PlayerAdded:connect(function(player)
plnum = plnum + 1
playerTbl[plnum] = player
for key, value in pairs(playerTbl) do print(key, value) end
end)
game.Players.PlayerRemoving:connect(function(player)
playerTbl[player] = nil
end)
repeat wait() until plnum > 0
local targetnum = math.random(1, #playerTbl or 1)
local targetname = playerTbl[targetnum]
repeat wait() until game.Workspace:FindFirstChild(targetname)
script.Parent.Target = game.Workspace:FindFirstChild(targetname):findFirstChild("Head")
wait(1)
script.Parent:Fire()
Every time I run this script, it always returns the following: Workspace.ball.RocketPropulsion.Script:16: bad argument #2 to 'random' (interval is empty)
I know this means that when it attempts to create random number using my parameters, the second number is set to 0, but when I attempt to add "repeat wait(1) until #playerTbl > 0" to prevent this, but when I do that it never breaks, and never moves on from that line.
More so, when I make it print the value of #playerTbl a line before I do the repeat line, it prints a value greater than 0 (1), and then returns this: Workspace.ball.RocketPropulsion.Script:22: attempt to index a nil value.
I am aware it probably is a stupid mistake on my part, but I've though this through a dozen times and I cannot for the life of me solve the problem.

4 comments
Well, now I just look stupid! Thank you very much for your help.
Oh yeah, and the snippet of code I gave you was only a portion of the actual script, and the list of players was necessary for that portion.
Whats the point of the repeat loop at the top? The script won't run until there's at least one player in the server, because otherwise the server wouldn't exist!
Perci1: I don't know if that's strictly true. The server could start up before the player is ready enough to actual have a Player object. Besides, without that, this code isn't modular enough to be used in a function or some other repeated loop.