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

Trouble creating teams from a script?

Asked by 9 years ago

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

Log in to vote
2
Answered by
Tkdriverx 514 Moderation Voter
9 years ago

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.

Ad
Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

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"

Answer this question