Having trouble with richtext in a script

  1. What do you want to achieve?
    I followed B Ricey’s tutorial, and wanted to change the player’s names to the color of their team.
  1. What is the issue?
    When I die, the richtext doesn’t work.

  1. What solutions have you tried so far?
    I’m not sure what solutions there are on richtext. I’m very confident that richtext is enabled. I made sure richtext is enabled on the text and enabled richtext on a script. I think something is wrong with the rich() function.
local htmlReset											= "</font>"

local function rich(color: Color3)
	return [[<font color=\"rgb(]].. color.R.. ", ", color.G.. ", ".. color.B .. [[)\">]]

print(rich(Color3.new(1, 0, 0)))
--<font color=\"rgb(1,  0, 0)\">

local attackerString = rich(enemyPlr.TeamColor.Color).. enemyPlr.Name.. htmlReset
local deadString = rich(plr.TeamColor.Color).. plr.Name.. htmlReset
local str = attackerString.. " killed ".. deadString.. "!"

--<font color=\"rgb(1, MalAllie</font> killed <font color=\"rgb(1, MalAllie</font>!
1 Like

I’m not sure why you are putting backward-slashes there. Also, the RGB properties of a Color3 object aren’t what you think. You will have to convert it to the HEX format. Also, you need to close the <font> tag with a </font> tag. Here’s a fixed function:

local function rich(text: string, color: Color3)
	return "<font color='#" .. color:ToHex() .. "'>" .. text .. "</font>"
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.