Team
The Team class represents a faction in a Roblox place. The only valid parent for a Team is in the Teams service.
Memory category | Instances |
---|
Member index 8
Description
The Team class represents a faction in a Roblox place. The only valid parent for a Team is in the Teams service. Teams offer a range of features that are useful to developers that can be divided into two rough groups:
- Features that work 'out of the box'
- Features developers can program into their game.
Built-in Team Behavior
The following functionality of Teams exists by default and does not require the developer to program any custom behavior.
- When part of a Team, the name above a player's character Model will be colored to the Team.TeamColor
- Changing Player.TeamColor will cause Player.Team to switch to the Team with the corresponding Team.TeamColor
- When using the default player list users will be grouped and displayed together as a team
- Setting Player.Neutral to true will cause the Player to be disassociated with the team, but it will not change Player.Team or Player.TeamColor
- When a Player joins a game, they will be allocated to the team with Team.AutoAssignable set to true that has the fewest players. If no auto assignable team is available, Player.Neutral will be set to true
- When SpawnLocation.Neutral is set to false, only players whose Player.TeamColor matches SpawnLocation.TeamColor can spawn on that SpawnLocation
- When SpawnLocation.AllowTeamChangeOnTouch is set to true, a player's Player.TeamColor will change to SpawnLocation.TeamColor when their character touches the SpawnLocation
Optional Extended Team Behaviors
Many developers chose to add the following features to teams in their own code.
- Implement checks in weapon code to prevent friendly fire.
- Implement checks in doors or other features that allow only certain teams to use them
- Periodically reassign teams to maintain team balance
History 33
- 648 Change ReturnType of GetPlayers from Objects to Instances
- 553 Change Default of TeamColor from to
- 553 Change Default of Score from to 0
- 553 Change Default of from to -1
- 553 Change Default of AutoColorCharacters from to true
- 553 Change Default of AutoAssignable from to true
- 533 Change ThreadSafety of GetPlayers from Unsafe to Safe
- 498 Change Parameters of PlayerRemoved from (player: Instance) to (player: Player)
- 498 Change Parameters of PlayerAdded from (player: Instance) to (player: Player)
- 486 Change ThreadSafety of TeamColor from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Score from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of AutoColorCharacters from ReadOnly to ReadSafe
- 486 Change ThreadSafety of AutoAssignable from ReadOnly to ReadSafe
- 462 Change ThreadSafety of PlayerRemoved from to Unsafe
- 462 Change ThreadSafety of PlayerAdded from to Unsafe
- 462 Change ThreadSafety of GetPlayers from to Unsafe
- 462 Change ThreadSafety of TeamColor from to ReadOnly
- 462 Change ThreadSafety of Score from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of AutoColorCharacters from to ReadOnly
- 462 Change ThreadSafety of AutoAssignable from to ReadOnly
- 442 Add
- 303 Add PlayerRemoved
- 303 Add PlayerAdded
- 248 Add GetPlayers
- 208 Change Tags of Score from [NotReplicated] to [NotReplicated, Deprecated]
- 208 Change Tags of AutoColorCharacters from [NotReplicated] to [NotReplicated, Deprecated]
- 47 Add TeamColor
- 47 Add Score
- 47 Add AutoColorCharacters
- 47 Add AutoAssignable
- 47 Add Team
Members 8
AutoAssignable
Type | Default | |
---|---|---|
bool | true |
This property determines whether Players will be automatically placed onto the Team when joining. If multiple teams have this property set to true, Roblox will attempt to even the teams out when Players are added.
When a Player joins a game they will be assigned to the Team with Team.AutoAssignable set to true that has the fewest players. If no such team is available, Player.Neutral will be set to true.
Note while using this property will help even out teams when players are added, it will not do anything when players are removed. For this reason developers may wish to implement their own team balancing system.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
History 4
- 553 Change Default of AutoAssignable from to true
- 486 Change ThreadSafety of AutoAssignable from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AutoAssignable from to ReadOnly
- 47 Add AutoAssignable
AutoColorCharacters
Type | Default | |
---|---|---|
bool | true |
Historically set whether or not Player character models on a team would be colored to Team.TeamColor.
Developers are advised not to use this property as the script which changed the team colors has since been removed from the default character. This property is deprecated and should not be used for new work.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
History 5
- 553 Change Default of AutoColorCharacters from to true
- 486 Change ThreadSafety of AutoColorCharacters from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AutoColorCharacters from to ReadOnly
- 208 Change Tags of AutoColorCharacters from [NotReplicated] to [NotReplicated, Deprecated]
- 47 Add AutoColorCharacters
GetPlayers
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Instances |
Returns a list of Players who are assigned to the Team. A Player is considered assigned if their Player.Team property is equal to the Team and Player.Neutral is false.
This function has a number of potential uses, including counting the number of players on a Team or giving every Player on a Team a Tool.
Thread safety | Safe |
---|
History 4
- 648 Change ReturnType of GetPlayers from Objects to Instances
- 533 Change ThreadSafety of GetPlayers from Unsafe to Safe
- 462 Change ThreadSafety of GetPlayers from to Unsafe
- 248 Add GetPlayers
PlayerAdded
Parameters (1) | |
---|---|
player | Player |
Fires whenever a Player is assigned to the Team. A player is considered assigned if their Player.Team property is equal to the Team and Player.Neutral is false.
This event is team specific and will only fire when a Player joints the specific Team. Any function connected to this event will be passed the Player object of the player who joined the team. For example:
Team.PlayerAdded:Connect(function(player)
print(player.Name.." has joined the team")
end)
Thread safety | Unsafe |
---|
History 3
- 498 Change Parameters of PlayerAdded from (player: Instance) to (player: Player)
- 462 Change ThreadSafety of PlayerAdded from to Unsafe
- 303 Add PlayerAdded
PlayerRemoved
Parameters (1) | |
---|---|
player | Player |
Fires whenever a Player is removed from a Team. This can be due to the Player leaving the game, Player.Neutral being set to true or the Player joining a different team.
This event is team specific and will only fire when a Player leaves the specific Team. Any function connected to this event will be passed the Player object of the player who left the team. For example:
Team.PlayerRemoved:Connect(function(player)
print(player.Name.." has left the team")
end)
Thread safety | Unsafe |
---|
History 3
- 498 Change Parameters of PlayerRemoved from (player: Instance) to (player: Player)
- 462 Change ThreadSafety of PlayerRemoved from to Unsafe
- 303 Add PlayerRemoved
Score
Type | Default | |
---|---|---|
int | 0 |
This property can be used to store an integer value associated with the team. This property offers no additional functionality and is not used by any game services.
This property is deprecated and should not be used by developers for new work.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
TeamColor
Type | Default | |
---|---|---|
BrickColor |
This property sets the color of the Team. Determines the Player.TeamColor property of players who are a member of the team.
A lot of Roblox's default team functionality is based on the team color, rather than the name or object. For example, SpawnLocations can be assigned to a team via SpawnLocation.TeamColor. For this reason it is recommended that developers ensure each Team has a unique TeamColor.
Any player which is a part of a team will have their name color changed to the team's TeamColor property. They will also be put underneath the team heading on the player list.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |