wait(7) function doTeam() local playerDir = game.Players:GetPlayers(); local chosen = table.remove(playerDir, math.random(1, #playerDir)); chosen.TeamColor = game.Teams["Bright red Team"].TeamColor; for index,value in next, playerDir do value.TeamColor = game.Teams["Bright blue Team"].TeamColor; end end doTeam();
Also its in a normal script.
What is the error? Have you run this in a test server?
From the information here, it seems that your script is correct. However, I'm guessing it's running at the wrong time.
This script will error in the event that there are no players joined at the time this script runs (which is seven seconds after server start).
Test using test servers and you will be able to find these things. The output is... sort of... necessary for you to program well.