How to convert a TeamColor into richtext?

Hi, I’m trying to make a pretty simple kill feed, and I’m trying to add the color of a players teamcolor to the richtext.

This is what I came up with, and ran it in the command console: (it doesn’t work, all paths are correct. the text changed, but it looks like the screenshot below)

local Team1 = game.Teams.HiddenTeams.knigt
game.StarterGui.MainUI.KillFeed.Frame.TextLabel.Text = [[<font color="rgb(]]..(Team1.TeamColor.Color.R*255)..[[,]]..(Team1.TeamColor.Color.G*255)..[[,]]..(Team1.TeamColor.Color.B*255)..[[)">Player1</font> destroyed]]

image

3 Likes

Maybe color tags need to have integer rgb values?

Try

local team_color = Team1.TeamColor.Color
local color_tag_format = [[color="rgb(%.0f, %.0f, %.0f)"]]
local color_tag = color_tag_format:format(team_color.R*255, team_color.G*255, team_color.B*255)
thing.Text = "<font %s>Player1</font> destroyed"):format(color_tag)

which gives results like <font color="rgb(26, 128, 255)">Player1</font> destroyed

or in general just use `“%.0f” to format a float with 0 decimals

1 Like

I solved this myself. You need to use math.floor() on the values.

Fixed:

local Team1 = game.Teams.HiddenTeams.knigt
local Team2 = game.Teams.HiddenTeams.viking
game.StarterGui.MainUI.KillFeed.Frame.TextLabel.Text = [[<font color="rgb(]]..(math.floor(Team2.TeamColor.Color.R*255))..[[,]]..(math.floor(Team2.TeamColor.Color.G*255))..[[,]]..(math.floor(Team2.TeamColor.Color.B*255))..[[)">Player1</font> destroyed]]
1 Like