TeamColor (Property)

From Legacy Roblox Wiki
Jump to navigationJump to search
TeamColor
Property BrickColor teamColor
Description Sets the color of the team.
Member of SpawnLocation, Team, Player


In SpawnLocations

If the Neutral property of the SpawnLocation is not set as true, then only players with the same TeamColor as the SpawnLocation's TeamColor will be able to spawn there.

In Teams

A Team's most important value is it's TeamColor, which decides the color of the Team. A Player with the same TeamColor as a Team will appear in the list of players on that team, and have their name shown in that color in the chat list.

In Players

If the Neutral property of the Player is not set as true, then the player will spawn only at SpawnLocations with the same TeamColor as they have. If the TeamColor of the Player does not match any existing Team in the Teams Service, then the player will NOT show up in the leaderboard, and their name will appear as black in the chat area.


Example
Here's a Script that, when a Player enters the game, creates a new Team, a new SpawnLocation, and a new TeamColor specific to that Player.
function onPlayerAdded( player )
   local playerTeam = Instance.new( "Team", game:GetService( "Teams" ) )
   playerTeam.Name = player.Name

   local TeamColor = BrickColor.Random()

   player.Neutral = false
   player.TeamColor = TeamColor
   playerTeam.TeamColor = TeamColor
   
   local playerSpawn = Instance.new( "SpawnLocation", Workspace )
   playerSpawn.Position = Vector3.new( math.random( -300, 300 ), math.random( -300, 300 ), math.random( -300, 300 ) )
   playerSpawn.Neutral = false
   playerSpawn.TeamColor = TeamColor
end

game.Players.PlayerAdded:connect( onPlayerAdded )