I'm trying to make a round system that'll randomly pick a player for a role, it does work when there is only one player, but fails when there are multiple players.
Snippet:
local RandomPlayer = game.Players:GetChildren()[math.random(1,#game.Players:GetPlayers())]
if RandomPlayer.Team.Name == "Lobby" then
RandomPlayer.TeamColor = BrickColor.new("Lapis")
RandomPlayer.Character:WaitForChild("Humanoid").JumpPower = 0
workspace.OfficeChair.Seat:Sit(RandomPlayer.Character:WaitForChild("Humanoid"))
game.ReplicatedStorage.NightGuardLocal:FireClient(RandomPlayer)
end
Output:
21:59:41.895 - ServerScriptService.Script:18: bad argument #2 to 'random' (interval is empty)
21:59:41.907 - Stack Begin
21:59:41.908 - Script 'ServerScriptService.Script', Line 18
21:59:41.908 - Stack End

2 comments
I hope this helped :)
Not sure if I wasn't waiting long enough, or if this just fixed the issue. (I was waiting 1 second), but either way thanks for the help!