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:
Any help would be appreciated
Thanks!