PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TeamColor

Team

BrickColor

This property sets the color of the Team. Determines the Player/TeamColor property of players who are a member of the team.

A lot of Roblox’s default team functionality is based on the team color, rather than the name or object. For example, SpawnLocations can be assigned to a team via SpawnLocation/TeamColor. For this reason it is recommended that developers ensure each Team has a unique TeamColor.

Any player which is a part of a team will have their name color changed to the team’s TeamColor property. They will also be put underneath the team heading on the player list.


Code Samples


Team Only Door

The following code sample will create a door in the Workspace that can only be walked through by Players on the Bright red team.

local Players = game:GetService("Players")

local door = Instance.new("Part")
door.Anchored = true 
door.Size = Vector3.new(7, 10, 1)
door.Position = Vector3.new(0, 5, 0)
door.Parent = game.Workspace

local debounce = false 

door.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		if hit then
			local player = Players:GetPlayerFromCharacter(hit.Parent)
			if player and player.TeamColor == BrickColor.new("Bright red") then
				door.Transparency = 0.5
				door.CanCollide = false 
				wait(3)
				door.Transparency = 0
				door.CanCollide = true
			end
		end
		wait(0.5)
		debounce = false
	end
end)