TextChatService System Message Font Color Help

Currently trying to make one of those Chat System messages that get sent in chat from time to time, problem is the :DisplayChatMessage() function creates its own font color, so I am never able to change the font color because it just breaks the whole rich text markup, I’ve seen these type of messages in a lof of games so I assume I’m doing something wrong. Any workarounds or fixes for this issue?

Part of script that handles the SystemMessage

local TextChatService = game:GetService("TextChatService")
	local TextChannels = TextChatService:WaitForChild("TextChannels") -- waitforchild is pointless when adding a wait at top but better be safe than sorry.
	local SystemChannel: TextChannel = TextChannels:WaitForChild("RBXSystem")

	local g = "<font size='18'><font face='FredokaOne'>TEST</font></font></font>"
	local h = string.gsub(tostring(g),"TEST",tostring(pickedTip))

	SystemChannel:DisplaySystemMessage(
		"<font color="..tostring(Color3.fromRGB(randomColor.R,randomColor.G,randomColor.B):ToHex())..">"..h
	)

What gets sent:
Image from Gyazo
(I’m assuming #d4d4d4 is the default text color)

1 Like

First off, I’m not fully sure if this will solve your issue but I’ve seen this cause similar issues in the past, when doing rich text markup like this you want to keep all of your sections in the same bracket.

Instead of:
"<font size='18'><font face='FredokaOne'>

Do:
"<font size='18' face='FredokaOne' etc.> TEXT </font>

Also FredokaOne might be Fredoka One from just looking at the Font Enum documentation:

Font | Documentation - Roblox Creator Hub

ANOTHER solution might be switching the "s with the 's since rich text markup can be picky sometimes

Will try these and update you in a minute, first time working with rich text markup and it’s incredibly confusing and overall a hassle IMO

1 Like

Okay so, I’ve tested with the sections, font name, and changed it up a little. I think the rich text markup itself is done correctly, but the problem lies within the function since it adds it’s own Font Color on top of my own.

Updated Script:

local TextChatService = game:GetService("TextChatService")
	local TextChannels = TextChatService:WaitForChild("TextChannels") 
	local SystemChannel: TextChannel = TextChannels:WaitForChild("RBXSystem")

	local g = string.gsub('<font color="COLOR" size="18" face="FredokaOne"> TEST </font>',"COLOR",tostring(Color3.fromRGB(randomColor.R,randomColor.G,randomColor.B):ToHex()))
	local h = string.gsub(tostring(g),"TEST",tostring(pickedTip))

	SystemChannel:DisplaySystemMessage(
		h
	)

What gets sent:
Image from Gyazo
(you can see my own font color which is the ed65ff and the default one which is #d4d4d4)

(NOTE: tested my rich text markup thing on a TextLabel just to check and it works just fine.)

I don’t know why it’s sending the first “automatic” color statement but I do notice your color’s hex value doesn’t have a #, this could cause it to not format properly

1 Like

It was the #. :man_facepalming:

Thank you very much!

1 Like

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