This is a Normal Script in the Workspace
--[[Rounds]] --[[Tables]] BrickColors = {BrickColor.new("White"), BrickColor.new("Black"), BrickColor.new("Medium stone grey")} function Team() --[[Number of players in each team]] for i,v in pairs(game.Players:GetChildren()) do WhiteTeam = 0 BlackTeam = 0 if v.TeamColor == BrickColor[1] then WhiteTeam = WhiteTeam + 1 elseif v.TeamColor == BrickColor[2] then BlackTeam = BlackTeam + 1 end --[[Putting players on Teams]] if WhiteTeam < BlackTeam then v.TeamColor = BrickColor[1] WhiteTeam = WhiteTeam + 1 elseif WhiteTeam > BlackTeam then v.TeamColor = BrickColor[2] BlackTeam = BlackTeam + 1 else v.TeamColor = BrickColor[1] WhiteTeam = WhiteTeam + 1 end end print "There are "WhiteTeam" players on the White Team" print "There are "BlackTeam" players on the Black Team" end --[[Reseting Players]] function Reset() for i,v in pairs(game.Players:GetChildren()) do v.TeamColor = BrickColors[3] end end --[[Firing]] while true do wait(4) Reset() wait(5) Team() end
Output:
20:46:57.786 - Workspace.Script:22: bad argument #3 to 'TeamColor' (BrickColor expected, got nil)
20:46:57.788 - Script 'Workspace.Script', Line 22 - global Team
20:46:57.789 - Script 'Workspace.Script', Line 42
20:46:57.790 - Stack End
Also if you know a way to make this more efficient, please improve/tell me.
EDIT: Line 3 I was using BrickColor**s** value, and calling BrickColor throughout the script, and you were right about the .. I just had to bracket the string
Try this. Tell me if it doesn't work.
--[[Rounds]] --[[Tables]] BrickColors = {BrickColor.new("White"), BrickColor.new("Black"), BrickColor.new("Medium stone grey")} function Team() --[[Number of players in each team]] for i,v in pairs(game.Players:GetChildren()) do WhiteTeam = 0 BlackTeam = 0 if v.TeamColor == BrickColors[1] then WhiteTeam = WhiteTeam + 1 elseif v.TeamColor == BrickColors[2] then BlackTeam = BlackTeam + 1 end --[[Putting players on Teams]] if WhiteTeam < BlackTeam then v.TeamColor = BrickColors[1] WhiteTeam = WhiteTeam + 1 elseif WhiteTeam > BlackTeam then v.TeamColor = BrickColors[2] BlackTeam = BlackTeam + 1 else v.TeamColor = BrickColors[1] WhiteTeam = WhiteTeam + 1 end end print "There are "..WhiteTeam.." players on the White Team" print "There are "..BlackTeam.." players on the Black Team" end --[[Reseting Players]] function Reset() for i,v in pairs(game.Players:GetChildren()) do v.TeamColor = BrickColors[3] end end --[[Firing]] while true do wait(4) Reset() wait(5) Team() end