Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Random players on team script?

Asked by 10 years ago

I need help making a script that randomly selects 2 players from the game and puts them on a team. Honestly, I've tried making the script myself, but it never works. I don't even know how to make the script, honestly, I just tried what I thought would work. Can anyone help?

1 answer

Log in to vote
0
Answered by 10 years ago
local players= game.Players:GetChildren()
local team = game.Teams.Team1

local plr1 = players[math.random(1,#players)]
local plr2
repeat
plr2 = players[math.random(1,#players)]
until plr2 and plr2 ~= plr1

plr1.TeamColor = team.TeamColor
plr2.TeamColor = team.TeamColor

Un-tested, hopefully works

Ad

Answer this question