Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Trouble creating teams from a script?

Im trying to create two teams but my script only creates the first team and it doesnt change the colour of the team, what am i doing wrong?

Instance.new("Team").Parent = game.Teams
game.Teams.Team.TeamColor = "Medium blue"
game.Teams.Team.Name = "Guards"

Instance.new("Team").Parent = game.Teams
game.Teams.Team.TeamColor = "Dark orange"
game.Teams.Team.Name = "Thieves"

2 answers

Your code isn't very pretty, I must say. May I suggest doing this:

local guards = Instance.new("Team", game.Teams)
guards.TeamColor = BrickColor.new("Medium blue") -- Note that TeamColor is a BrickColor value
guards.Name = "Guards"

local thieves = Instance.new("Team", game.Teams)
thieves.TeamColor = BrickColor.new("Dark orange")
thieves.Name = "Thieves"

This method is cleaner and easier to read. It also allows you to re-access the teams later on if you need them for your code by using the variables.

You're supposed to use a BrickColor value instead of string values. Due to this, the script does not know what to do, and breaks.

Instance.new("Team").Parent = game.Teams
game.Teams.Team.TeamColor = BrickColor.new("Medium blue") --BrickColor Value Added.
game.Teams.Team.Name = "Guards"

Instance.new("Team").Parent = game.Teams
game.Teams.Team.TeamColor = BrickColor.new("Dark orange") --BrickColor Value Added.
game.Teams.Team.Name = "Thieves"

This discussion is preserved as it was. New answers, comments, and votes are closed.