Class
Teams
NotCreatableService
The Teams service holds a game's Team objects. Team objects
must be parented to the Teams service.
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 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
Modelwill be colored to theTeam.TeamColor - Changing
Player.TeamColorwill causePlayer.Teamswitch to the Team with the correspondingTeam.TeamColor - When using the default player list users will be grouped and displayed by team
- Setting
Player.Neutralto true will cause thePlayerto be dis-associated with the team, but will not changePlayer.TeamorPlayer.TeamColor - When a
Playerjoins a game, they will be allocated to the team withTeam.AutoAssignableset to true that has the fewest players. If no auto assignable team is available,Player.Neutralwill be set to true - When
SpawnLocation.Neutralis set to false, only players whosePlayer.TeamColormatchesSpawnLocation.TeamColorcan spawn on thatSpawnLocation - When
SpawnLocation.AllowTeamChangeOnTouchis set to true, a player'sPlayer.TeamColorwill change toSpawnLocation.TeamColorwhen their character touches theSpawnLocation
Optional extended team behavior Many developers chose to add the following features to teams in their own code.
- Implement checks for team in weapon code to prevent team killing
- Implement doors or other features that only certain teams can use
- Periodically reassign teams to maintain team balance
Methods 2#
| GetTeams | Returns a table containing the game's Team objects. Will only
return Team objects that are parented to the Teams
service. |
| RebalanceTeams | Evens the number of people on each team. This function does not work correctly and should not be used.Deprecated |
GetTeams(): List<Team>#
The GetTeam function returns a table containing the game's Team
objects.
Note this will only return Team objects that are directly parented to the
Teams service. For this reason it is recommended developers only
parent Team objects to the Teams service and not to other
Instances (or to each other).
Returns
List<Team>— An array ofTeamsin the game.
RebalanceTeams(): ()#
DeprecatedDeprecated
Deprecated. This function has been deprecated and no longer functions correctly. It should not be used. Developers should instead implement their own team sorting systems.
Evens the number of people on each team. This function does not work correctly and should not be used.
Returns
()
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild