Rich Text Custom Color On Specific Item

So I’ve recently trying to make rich text color on specific item like yellow color text is for yellow trail, blue color text is for blue trail. But I’m getting stuck and confused how do i do it.

image

  • No errors in output
ownedTrailsFolder.ChildAdded:Connect(function(item)
	local function rgb255RichText(color3)
		local R = (color3.R * 255)
		local G = (color3.G * 255)
		local B = (color3.B * 255)
		
		return string.format("rgb(%d, %d, %d)", R,G,B)
	end
	
	local rgbText = rgb255RichText(Color3.fromRGB(item.Color))

	script.Parent.NotificationBar.Text = [[Purchased New Item: <font color="]] .. rgbText .. [["\>"]] .. item.Name .. " Trail</font>"
		
end)

Remove the [["\>]] and replace it with [[">"]], you only need one backwards slash.

It’s working but the colour for it became black colour

local function rgb255RichText(color3)
		local R = (color3.R * 255)
		local G = (color3.G * 255)
		local B = (color3.B * 255)
		
		return string.format("rgb(%d, %d, %d)", R,G,B)
	end

The whole RGB * 255 is useless because RGB caps out at 255 and no matter what value you pass it will either be white or black.

Assuming your item color is generated using Color3 you can just pass in item.Color as your argument for rgb255RichText.

local function rgb255RichText(color3)
	return string.format("rgb(%d, %d, %d)", color3.R,color3.G, color3.B)
end

Sadly, It’s still become black colour too

Could you send the updated code?
And by any chance print out the value of item.Color, rgbText along with the result of Color3.fromRGB(item.Color)

here’s the full one

ownedTrailsFolder.ChildAdded:Connect(function(item)
	
	local function rgb255RichText(color3)
		return string.format("rgb(%d, %d, %d)", color3.R,color3.G, color3.B)
	end
	
	local rgbText = rgb255RichText(Color3.fromRGB(item.Color))
	
	NotificationSound:Play()
	script.Parent.InventoryButton.Notification.Visible = true
	
	Notif = true
	script.Parent.NotificationBar.Visible = true
	script.Parent.NotificationBar.Text = [[Purchased New Item: <font color="]] .. rgbText .. [[">"]] .. item.Name .. " Trail</font>"

	--script.Parent.NotificationBar.Text = "Purchased New Item: <font color=\"rgb(255,255,0)\">".. item.Name .. " Trail </font>"
	
	updateInventory(); updateShop()
	task.wait(10.5)
	script.Parent.NotificationBar.Visible = false
	
end)

So i put some prints on it and it shows this

Print Code

local rgbText = rgb255RichText(Color3.fromRGB(item.Color))
print(rgbText)

Output

  rgb(0, 0, 0)

Try taking out Color3.fromRGB and only pass in item.Color for rgb255RichText

	local rgbText = rgb255RichText(item.Color)

sadly errors appeared on the output

ERROR

  'R' is not a member of ColorSequence
  Stack Begin
  Script 'Players.Humaidi_0.PlayerGui.ScreenGui.TrailGuiHandler', Line 127 - function rgb255RichText
  Script 'Players.Humaidi_0.PlayerGui.ScreenGui.TrailGuiHandler', Line 130
  Stack End

Late to the party but when you read the color components of a Color3, they’ll automatically be uniform [0-1].

You will need to keep the Color3.SomeComponent * 255

@Humaidi_0 ^

Do you want an exact color? If not do

local rgbText = Instance.New(Color, <Name of color here>)

Oh okay I will try and I will inform you later on

Since I’ve been trying to do it, so I decided

Ima just gonna set the item color to green instead