Converting the Player's named TeamColor into a Color3?

I’m trying to turn the TextColor3 of a TextLabel into the same color as the TeamColor of the Team the Player is currently on. I’ve tried converting it to RGB, but it doesn’t seem to work.

Anybody have any ideas on how to get this to work?

		local TeamColor = Player.Team.TeamColor
		local TeamR = TeamColor.r
		local TeamG = TeamColor.g
		local TeamB = TeamColor.b
		nameLabel.TextColor3 = Color3.fromRGB(TeamR, TeamG, TeamB)

I can’t just simply do nameLabel.TextColor3 = TeamColor because specific and named colors are incompatible.

Reminder :
TeamColor is a BrickColor.
To ‘access’ the R,G,B values, you need the Color3.

Try get its color try -

local TeamColor = Player.Team.TeamColor.Color
local R,G,B = TeamColor.R,TeamColor.G,TeamColor.B

nameLabel.TextColor3 = Color3.fromRGB(R,G,B)

alternatively:

local TeamColor = Player.Team.TeamColor
local R,G,B = TeamColor.r,TeamColor.g,TeamColor.b

nameLabel.TextColor3 = Color3.fromRGB(R,G,B)

For me, these 2 worked.

1 Like

Shortened.

nameLabel.TextColor3 = Player.Team.TeamColor.Color

https://developer.roblox.com/en-us/api-reference/datatype/BrickColor

2 Likes

None of these worked. These aren’t really any different than what I did originally, either…
Returns no errors in the Output.

Looks like error comes from outside of that.
1: LocalPlayer only works in LocalScript, that only works in client.
2: Are you sure you are using Roblox’s team system?

I assume the text color becomes black, that’s because the .r, .g, .b values are normalized between 0 and 1, but Color3.fromRGB accepts values that are between 0 and 255. The solution is to either multiply with 255 or use Color3.new that accepts 0-1 values. Therefore:

Color3.new(TeamColor.r, TeamColor.g, TeamColor.b)
--and
Color3.fromRGB(TeamColor.r*255, TeamColor.g*255, TeamColor.b*255)

‘TeamColor’ is a ‘BrickColor’ value, all you need to do is index its ‘Color’ property to retrieve the ‘Color3’ value equivalent.

TextLabel.TextColor3 = Player.TeamColor.Color

https://developer.roblox.com/en-us/api-reference/datatype/BrickColor#properties

2 Likes