Teams

Teams

This class is a Service! It is a top-level singleton which can be retrieved using the ServiceProvider/GetService|GetService function.

NotCreatable

This object cannot be created with the Instance|Instance.new constructor function.

The Teams service holds a game’s Team objects. Team objects must be parented to the Teams service.

Teams offer a range of features that are useful to developers. These can broadly be divided into features that work out-of-the-box and features developers can program into their game.

Built-in team behaviour
The following functionality of Teams exists by default and does not require the developer to program any custom behaviour.

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 switch to the Team with the corresponding Team/TeamColor

When using the default player list users will be grouped and displayed by team

Setting Player/Neutral to true will cause the Player to be dis-associated with the team, but 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 behavior
Many developers chose to add the following features to teams in their own code.

Code Samples

Team Kill Check

This code sample includes a quick function that can be added to weapons in a place to prevent them from team killing. It will return false when the two players are on different teams or if either of them is neutral.

Simple Team Rebalance

This code sample includes a simple example of how to re-balance teams. When Team.AutoAssignable is set to true players will be added to Teams in a balanced fashion. However as Players leave the game this can lead to unbalanced teams as players are not reallocated. This code keeps track of the number of players in each team and, when players leave will check to see if the teams need re-balancing.

How this site use cookies

This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.