local plrs = game.Teams.lobby:GetPlayers() player = math.random(1,#plrs) print(player.Name)
The error is telling you that there are no values inside of the plrs table. I believe this is because players are added during runtime while this script checks instantly (I'm assuming this is the only thing in your script). In order to fix this, you could either wait until a player joins by using a PlayerAdded event inside of a Server Script, or you could just wait for the character using a Local Script.
Server Script
game.Players.PlayerAdded:Connect(function(plr) local plrs = game.Teams.lobby:GetPlayers() local randomPlayer = plrs[math.random(1, #plrs)] print(randomPlayer.Name) end
Local Script
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() --waits until the localplayer's character is loaded which is enough time for the player to join the team local plrs = game.Teams.lobby:GetPlayers() local randomPlayer = plrs[math.random(1, #plrs)] print(randomPlayer.Name)
First of all, try using the following format when writing code (it just clears things up a bit);
print("See, this is how code should be formatted on this site.")
Next, we are going to need quite a bit more information than you've given us. What are you trying to accomplish here? What is the result you hope for, and is anything happening other than that error? Please reply with more information (and maybe proper formatting) if you want an answer.