local msg = Instance.new('Message',workspace) msg.Text = "Now choosing teams..." wait(5) msg:Destroy() local team1, team2 = 'Red', 'Blue'; repeat team1, team2 = Game:GetService'Teams':FindFirstChild(team1), Game:GetService'Teams':FindFirstChild(team2) wait(1/30) until team1 and team2 for i, player in pairs(Game:GetService'Players':GetPlayers'') do player.TeamColor = i%2==0 and team1.TeamColor or team2.TeamColor end
The problem is that it wont split the teams, correctly..
First of all: Nice coding style - good use of the and
and or
operators.
It should work. However, your repeat-until
block has a kind of unlogic meaning: it will only run once in any case, while it is intended to wait for the team1
and team2
variables.
What would be better? Well, just use :WaitForChild
. Delete line 7, 8 and 9 and instead put on line 5:
local teams = game:GetService("Teams") -- this is how I write it down but yours is also correct! local team1, team2 = teams:WaitForChild("Red"), teams:WaitForChild("Blue")
Test that, because it should work.