Skip to Content

Teams

Service for creating and querying teams and spawn locations, balancing players and resolving damage rules.

local Teams = game:GetService("Teams")

Teams can be defined in Studio or created at runtime. Each team is a Team object and each spawn location is a Spawn.

Properties

AllowSwitching

Teams.AllowSwitching: boolean

When true, players can choose their own team.

Methods

CreateTeam

Teams:CreateTeam(settings: table): Team

Creates and returns a team. Name is required and must be unique.

local red = Teams:CreateTeam({
	Name = "Red",
	Color = Color3.fromRGB(230, 60, 60),
	Description = "Defend the base",
	MaxPlayers = 8,
})

CreateSpawn

Teams:CreateSpawn(settings: table): Spawn

Creates and returns a spawn location. Position is required. Team and Neutral are optional.

Teams:CreateSpawn({ Position = Vector3.new(0, 2, 50), Team = red })

GetTeams

Teams:GetTeams(): { Team }

Returns every team.

FindFirstChild

Teams:FindFirstChild(name: string): Team?

Returns the team with the given name, or nil.

GetSpawns

Teams:GetSpawns(): { Spawn }

Returns every spawn location.

Balance

Teams:Balance()

Redistributes players to even out team sizes.

CanDamage

Teams:CanDamage(attacker: Player, target: Player): boolean

Returns true if attacker may damage target under the current team and friendly-fire rules.

On this page