Rich Text displays code instead of working like normal

I’m trying to use rich text to customize dialogue, but it keeps displaying the html tags instead of changing the text style. I’m positive rich text is active, and I’ve looked for a solution to no avail.
Rich Text module:

--This is the module I use to customize text with Rich Text
local text = {}

text.Styles = {
	["Bold"] = "b",
	["Italic"] = "i",
	["Underline"] = "u",
	["Strikethrough"] = "s",
	["Smallcaps"] = "sc",
	["Font"] = "font",
	["Stroke"] = "stroke"
}

text.Fonts = {
	["Fondamento"] = "Fondamento",
	["Inconsolata"] = "Inconsolata",
	["Special Elite"] = "Special Elite"
}

text.Break = "<br />"

function text.Color(color : Color3)
	return 'color="rgb(' .. tostring(math.floor(color.R*255)) .. ',' .. tostring(math.floor(color.G*255)) .. ',' .. tostring(math.floor(color.B*255)) .. ')"'
end

function text.FontFace(font : string)
	return 'face="' .. font .. '"'
end

function text.Encase(origin_text : string, encaser : string, extra_styles : table)
	local encaser_tag = "<" .. encaser --Leave open for extra styles
	local closer_tag = string.gsub(encaser_tag .. ">", ">", "/>")

	--Add extra styles
	if extra_styles then
		for _, style in pairs(extra_styles) do
			encaser_tag = encaser_tag .. " " ..style
		end
	end

	--Close encaser
	encaser_tag = encaser_tag .. ">"

	return encaser_tag .. origin_text .. closer_tag
end

return text

Script:

local styler = require(script.Parent:WaitForChild("test"))

local testTextSpeaker = styler.Encase("Tester: ", styler.Styles.Font, {styler.FontFace(styler.Fonts.Fondamento), styler.Color(Color3.fromRGB(255, 150, 150))})
local testTextSpoken = styler.Encase("this is a test.", styler.Styles.Font, {styler.FontFace(styler.Fonts.Inconsolata), styler.Color(Color3.fromRGB(150, 150, 255))})
script.Parent.Text = testTextSpeaker .. testTextSpoken

Result:
Screen Shot 2025-01-27 at 8.46.18 PM

Any help would be appreciated
Thanks! :slight_smile:

2 Likes

image
This should be </font>, not <font/>

1 Like

realized how stupid I am for missing that lol :sob:
didn’t work though, ended up with this:
Screen Shot 2025-01-27 at 9.01.33 PM

printed it out in output just in case

<font face="Fondamento" color="rgb(255,150,150)">Tester: </font><font face="Inconsolata" color="rgb(150,150,255)">this is a test.</font>

The issue in it now seems to be this: Inconsolata. Changing it with any other font (e.g. Arial) makes it work fine, however Inconsolata doesn’t seem to exist.

Just tested this and it works. Thanks!
Strange, though, and it’s a shame I can’t use that font even though I find it in the font menu on Studio
Screen Shot 2025-01-27 at 9.15.14 PM

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