Codectionary / Developer documentation / Luau

Teams

Organize players into teams with team colors and assignments.

Why use Teams?

The Teams service stores Team instances. Assigning Player.Team can support team-based spawning and UI, but scoring and permissions still need game-specific server logic.

Try it in Roblox Studio

Put this Script in ServerScriptService. When players join a Studio test session, they are assigned to the created Blue team.

Syntax

player.Team = team

Examples

Teams

Create a team and assign joining players.

local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local blue = Instance.new("Team")
blue.Name = "Blue"
blue.TeamColor = BrickColor.new("Bright blue")
blue.AutoAssignable = false
blue.Parent = Teams

Players.PlayerAdded:Connect(function(player)
    player.Team = blue
end)
  1. The Team instance belongs under the Teams service.
  2. AutoAssignable = false leaves assignment to this server script rather than automatic balancing.
  3. PlayerAdded runs for newly joining players. Existing players need separate handling if the script is inserted during a running session.

Best practices

  • Assign and validate authoritative team state on the server.
  • Coordinate SpawnLocation team colors if using team-specific spawns.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading