Got help from very helpful dudes, and this is what left that they could not figure out:
The error that is getting spit out is - 8: bad argument #1 to 'random' (interval is empty)
TeamName = "Monster"
players = game.Players:GetPlayers()
selected = ""
function SelectPlayer()
if #players ~= 1 then
print(#players)
local num = math.random(game.Players.NumPlayers)
selected = players[num]
else selected = players[1] end
end
SelectPlayer()
function TeamPlayer(player)
local play = game.Players:FindFirstChild(player.Name)
local team = game.Teams:FindFirstChild(TeamName)
if play~= nil then
play.TeamColor = team.TeamColor
end
end
TeamPlayer(selected)

2 comments
I'm pretty sure you just asked this question, and it got 3 answers. https://scriptinghelpers.org/questions/54057/why-is-this-random-1-person-team-selector-not-working . It's not working because #players is 0, because you defined it at the beginning, when there were no players. Use: local num = math.random(1,#game.Players:GetPlayers())
dude, this question has been posted more than 3 times, I remember at least 15 posts like this