i am trying to get 2 random players (playerA and playerB) but i get this error when i start test: ServerScriptService.main:16: bad argument #2 to 'random' (interval is empty)
local playerA = nil
local playerB = nil
local started = false
while wait() do
wait(1)
if not started then
if playerA == nil then
local players = game.Players:GetChildren()
local randomplayer = players[math.random(1,#players)]
if randomplayer == playerB then
repeat
local randomplayer = players[math.random(1,#players)]
until randomplayer ~= playerB
playerA = randomplayer
else
playerA = randomplayer
end
print(playerA)
end
if playerB == nil then
local players = game.Players:GetChildren()
local randomplayer = players[math.random(1,#players)]
if randomplayer == playerA then
repeat
local randomplayer = players[math.random(1,#players)]
until randomplayer ~= playerA
playerB = randomplayer
else
playerB = randomplayer
end
print(playerB)
end
end
end

1 comment
This script is ridiculously complicated for something that just needs to pick two values.