TeamColor (Property)

From Legacy Roblox Wiki
Revision as of 21:28, 13 January 2011 by >ArceusInator (example)
Jump to navigationJump to search

The TeamColor property are a member of Player, Team, and SpawnLocation objects. TeamColor is a BrickColor value for all three objects.

In SpawnLocations

If the Neutral property of the SpawnLocation is not set as true, then only players with the same TeamColor as the SpawnLocatoin'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.


TeamColor
Property BrickColor team color
Description Sets the color of the team.
Member of [[RBX.lua.SpawnLocation, Team, and Player (Object)|SpawnLocation, Team, and Player]]
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 )