How do I enable RichText for this TextChatService ChatVersion?

Hello Developers,

I’m currently need the rich text enabled for this new chat window. If you have a solution then can you please help me? Thank you soo much!!

image

2 Likes

RichText works with TextChatService by default assuming you are using :DisplaySystemMessage. Your string is not valid rich text because you need to escape your angle brackets (replace them with < and >)

If you want a catch-all function, here you go.

local function makeTextRichTextable(rawText: string)
	return rawText:gsub('&', '&amp;'):gsub('[<>"\'"]', { -- ensure ampersands get replaced first because our escapes will be escaped, so the player will literally see "&lt;" in the case of wanting to replace <
		['<'] = '&lt;';
		['>'] = '&gt;';
		['"'] = '&quot;';
		['\''] = '&apos;';
	})
end

-- use:
script.Parent.MouseButton1Click:Connect(function()
	local message = `<font color="rgb(255, 0, 0)">{ makeTextRichTextable('"\'<hello there & have a good day>\'"') }</font>`
	game:GetService('TextChatService'):WaitForChild('TextChannels'):WaitForChild('RBXGeneral'):DisplaySystemMessage(message)
end)

image

1 Like

Thanks, I will try it tomorrow to see if that works then let you know :slight_smile:

3 Likes

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