Skip to content
Untitled Sandbox - Developer Documentation
docs/api/teams

@usbx/teams

Teams and friendly fire

local teams = require("@usbx/teams")

teams.all

function

Every team, in the order of the Teams service.

teams.all() -> { Team }
example
for _, team in teams.all() do print(team.name) end

Use it forlisting the teams on a scoreboard, or balancing how many players each team has.

teams.find

function

Finds a team by its name, or gives nil.

teams.find(name: string) -> Team?
example
local red = teams.find("Red")

Use it forgrabbing the Red or Blue team so you can move players onto it.

nameName of the team.

teams.create

function

Adds a team after the others and returns it. With the name of a team that exists, it returns that team and gives it the options.

teams.create(name: string, options: { … }?) -> Team
example
local blue = teams.create("Blue", { color = math3d.color.rgb(0, 0, 255) })

Use it forsetting up the teams for a match when the round starts.

nameName of the new team, 1 to 30 characters.
optionsoptionalIts color and whether joining players go on it.
Build a create callcolor · auto_assign
  • color

    The team's color, which is white when you leave it out.

  • auto_assign

    Whether players who join can be put on this team, which is false when you leave it out.

teams.changed

event

Fires when a player's team changes, with the player, the old team and the new team.

teams.changed: Event<(Player, Team?, Team?)>
example
teams.changed:connect(function(player, _old, new) if new then print(player.name, "joined", new.name) end end)

Use it forgiving players team gear or a team color whenever they switch teams.

teams.friendly_fire

value

While false, the default, Player:damage by a teammate does nothing. Writable.

teams.friendly_fire: boolean
example
teams.friendly_fire = true

Use it forfree for all modes, where teammates are allowed to hurt each other too.

↑ ↓ moveEnter openEsc close