Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making RichText and string.sub (Typewriter effect) compatible with each other?

Not long ago Roblox added a new feature, RichText. It allows different text in a text label to have different colour, size, font, etc... However, when RichText is combined with string.sub also know as a typewriter effect, this happens since RichText tags need a <> and </>.

I found this off the Roblox Developer Forum to bold a string of text.

local textToType = "The quick brown fox jumps over the lazy dog.";
local richTextTemplate = "<b>%s</b>"

for i = 1, textToType:len() do
	script.Parent.Text = richTextTemplate:format(textToType:sub(1, i))
	wait()
end

However, my text is stored like this:

Text = "The quick <font color='rgb(106, 57, 9)'>brown</font> fox jumps over the lazy dog."

So that way would not be possible to do as it will colour the entire string instead of just one word or if I wanted to sub in the player's name

Text = "Hey <font color='rgb(106, 57, 9)'>%s</font>, welcome to my game!"

where %s will be used with string.format(Text, Player's Name)

What's the best way to make both of them compatible given the situation I have? Any tips or help would be appreciated! Thanks in advance.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.