How do i make , so that a script selects a random player, puts it in the team "Monster" and displays a message that he is the monster. tried this - didnt work.
TeamName = "Monster"
players = {}
selected = ""
function GetPlayers()
for _,v in pairs(game.Players:GetChildren()) do
table.insert(players,v)
end
end
GetPlayers()
function SelectPlayer()
local num = math.random(1, #players)
selected = players[num]
print('Selected player was: ' ..selected)
end
SelectPlayer()
function TeamPlayer(player)
local play = game.Players:FindFirstChild(player)
local team = game.Teams:FindFirstChild(TeamName)
if play~= nil then
play.TeamColor = team.TeamColor
end
end
TeamPlayer(selected)

3 comments
Seems like Selected is blue underlines, it is not defined. How can i fix that?
And it prints out nothing. No errors
Thats because it was supposed to be "local" selected. My bad, but I've edited that.