Want a special badge and 30 bux? Make some PolyWorld! Content and post it in the Creations forum!
Dark mode is incomplete! Please report any issues to the Discord.

TeamsModule

Scripts Not creatable

TeamsModule creates named, colored teams and assigns players.
Team colors tint chat names, nametags, and the player list.
Available as the global TeamsModule.


Overview

Properties

Methods


API

Properties

AutoColorNames

AutoColorNames : bool
When true (default), Assign sets the player's `CustomNameColor` to the team color.
Clearing a team (Assign with nil) clears that color override.
Set to false if you want to color names yourself.

TeamsModule.AutoColorNames = true
Methods

Create

Create(name: string, color: Color) : void
Creates or updates a team.
color is an RGB Color (0–1 channels, or 0–255 via RGBColor.new).
Up to 16 teams. Names are case-sensitive and at most 23 characters.

TeamsModule:Create("Red", RGBColor.new(220, 60, 60))
TeamsModule:Create("Blue", RGBColor.new(60, 120, 255))

Remove

Remove(name: string) : void
Deletes a team. Players on that team become unassigned.

Assign

Assign(player: Player, teamName: string?) : void
Puts the player on teamName, or clears their team when teamName is nil.
Errors if the team name is unknown.

TeamsModule:Assign(player, "Red")
-- later:
TeamsModule:Assign(player, nil)

GetTeam

GetTeam(player: Player) : string?
Returns the player's team name, or nil.

Also available as `player.Team`.

GetColor

GetColor(teamName: string) : Color?
Returns the team's color, or nil.

GetPlayers

GetPlayers(teamName: string) : List of Players
Players currently on that team.

GetTeams

GetTeams() : List of tables
Returns { Name, Color } for each team.


Player list

When any team exists, the player list groups people under colored team headers.
Players with no team appear under No Team.
Combine with StatsModule for score columns beside each name.

TeamsModule:Create("Red", RGBColor.new(220, 60, 60))
TeamsModule:Create("Blue", RGBColor.new(60, 120, 255))
StatsModule:Define("Kills", { Save = true })

Players.PlayerAdded:Connect(function(player)
    local n = #TeamsModule:GetPlayers("Red")
    local m = #TeamsModule:GetPlayers("Blue")
    TeamsModule:Assign(player, n <= m and "Red" or "Blue")
end)