§ How to · with Picoo

How to make teams and team spawns in Roblox

By Sametcan Tasgiran, Founder & Developer·Published ·Updated

Roblox teams are linked to spawns by colour, which is elegant right up until two teams share a colour and players start spawning in the wrong base.

Teams, spawns and balance are three small systems that only work when the colour contract between them is exact.

Teams and spawns linked

SpawnLocation.TeamColor matched to each team, with Neutral off so spawns are exclusive.

Auto-balance

Joining players go to the smaller team; imbalance from leavers is corrected between rounds.

Manual switching

A team picker with server-side rules — locked teams, capacity limits, cooldowns.

Respawn on switch

Changing team moves the character to the new base instead of leaving it in the old one.

Team-aware damage

Friendly fire as a single configurable rule rather than a check in every weapon.

Team scores

Per-team scoring that survives players leaving and rejoining.

Files Picoo ships for this prompt

2 files · 165 lines · ~25s · 1 credit

TeamService

Team creation, assignment, balancing, switch rules, scores.

110 lines

TeamPickerUI

Team selection with live counts and lock states.

55 lines

Sample output: ServerScriptService.TeamService

-- Roblox links a player to a spawn by COLOUR, not by reference. Two teams with
-- the same TeamColor is therefore ambiguous, and players start appearing in the
-- wrong base with nothing in the output to explain it. Colours must be unique.
local function makeTeam(name: string, colour: BrickColor): Team
	for _, t in Teams:GetTeams() do
		assert(t.TeamColor ~= colour, "duplicate TeamColor: " .. name)
	end
	local team = Instance.new("Team")
	team.Name, team.TeamColor = name, colour
	team.AutoAssignable = false      -- we assign deliberately, for balance
	team.Parent = Teams
	return team
end

-- A SpawnLocation only belongs to a team when Neutral is FALSE. Left true (the
-- default), it accepts everyone and TeamColor is ignored entirely — the usual
-- reason "my team spawns aren't working".
local function bindSpawn(spawn: SpawnLocation, team: Team)
	spawn.Neutral = false
	spawn.TeamColor = team.TeamColor
end

-- Switching teams does NOT move an existing character. Without this the player
-- changes team and keeps standing in the enemy base.
local function assign(plr: Player, team: Team)
	plr.Team = team
	plr.Neutral = false
	plr:LoadCharacter()
end

Building teams and team spawns in Roblox

Roblox's Teams service does more than it appears to, and its one design quirk causes most of the bugs people hit.

The quirk is that players are matched to spawn points by colour. A SpawnLocation has a TeamColor, a Team has a TeamColor, and the engine pairs them by value. It works beautifully with two or three teams and breaks the instant two teams share a colour, because now the pairing is ambiguous and players start appearing at the wrong base with nothing in the output window to explain it. Asserting that colours are unique when you create teams is three lines and saves an evening.

The companion mistake is Neutral. A SpawnLocation with Neutral left true — the default — accepts everybody, and its TeamColor is simply ignored. So you set the colours correctly, test, and find everyone still spawning anywhere. Setting Neutral to false is what makes a spawn belong to a team at all.

The third is that changing Player.Team does not move the character. Team is used when a character next spawns, so a player switched mid-round keeps standing exactly where they were, frequently inside the base they just stopped belonging to. Calling LoadCharacter after the switch is what people expect the assignment itself to do.

Balance is the design question rather than the API one. Assign new joiners to the smaller team yourself instead of leaving AutoAssignable on, so you control the rule. Rebalance between rounds rather than during them — being teleported out of a fight to even the numbers feels worse than the imbalance did. And recheck when players leave, because leavers, not joiners, are what actually unbalances a match.

See more on the Luau generator, the game builder, or browse the full blog.

Frequently asked

Why do players spawn on the wrong team's spawn?+

Either two teams share a TeamColor — Roblox matches players to spawns by colour, so identical colours are ambiguous — or the SpawnLocation still has Neutral set to true, in which case it accepts everyone and its TeamColor is ignored. Both fail silently, which is why this one costs people an evening.

Why doesn't the player move when I change their team?+

Setting Player.Team affects future spawns, not the character standing in the world. Call player:LoadCharacter() after switching, or the player changes team and stays exactly where they were, usually inside the enemy base.

How do I auto-balance teams?+

Assign new joiners to the smallest team rather than letting AutoAssignable do it, and rebalance between rounds instead of mid-round — moving someone mid-fight is worse than a one-player imbalance. Balance on player count, and recheck on PlayerRemoving, since leavers are what actually unbalances a match.

How should friendly fire work?+

As one rule in one place — the damage path — not a check in each weapon. Put the same-team test inside the function that applies damage, and a new weapon cannot forget it.

Do I need the Teams service at all?+

For anything where players spawn separately, see each other on the leaderboard by side, or have friendly fire, yes — you get spawn binding, the grouped player list and Player.Team for free. For a temporary in-round grouping with no spawn implications, an attribute is lighter.

Related Picoo prompts