So this code seems to work just fine running it in Studio, But when I test it on the Client and Servers option it give me the error:
ServerScriptService.PlayerChooser:20: bad argument #2 to 'random' (interval is empty)
local vPlayers = game.Players.NumPlayers local vPlayer = game.Players.LocalPlayer while wait(1) do vPlayerAmount = {} for _, vPlayer in pairs(game.Players:GetPlayers()) do if vPlayer and vPlayer.Character then local vHumanoid = vPlayer.Character:WaitForChild("Humanoid") if vHumanoid and vHumanoid.Health > 0 then table.insert(vPlayerAmount, vPlayer) end end end if #vPlayerAmount <= 2 then vSimonP = vPlayerAmount[math.random(1, #vPlayerAmount)] if vSimonP then vSimonP.Team = game.Teams.Simon end end end
I'm guessing it has to do with the table but i'm not sure what I should fix! Any help is appreciated!