How can I eliminate RichText from my For loop?

Hello! I hope you are having a great day! I had a great day raging at some of the games in the Metaverse event!


However thats not the point. I have a little problem.

	script.Parent.Text = 'Hello! I am <font color="#FFA500">Haran</font>. What is your name?'
	local amountOfText = string.len(script.Parent.Text)
	for i = 1, amountOfText do
		script.Parent.MaxVisibleGraphemes = i
		wait(0.01)
		script.Parent.Parent.Parent.ChatSound:Play()
	end

So a sound plays whenever the text gets typed. I want to use Roblox’s new Typewritter system, but since I am using RichText, the sound plays extra amount of times.


If you can help, please let me know. Thanks! WE
P.S. I don’t want to use a fancy module anymore. I just want to keep it simple.

Maybe try using utf8.len? I don’t know much about RichText

Well the thing is, RichText is a UTF8 character.

Tried anyway, didn’t work.

If your trying to make a typewriting effect do this:

local text = "what ever you want"
local textLabel = script.Parent
for digit = 1, #text do
textLabel.Text = string.sub(text,1,digit)
wait(0.1) -- Time per character typed.
end

You could probably just store the plain text inside a variable and then loop over that text instead of the RichText with all the tags.

Roblox had a property for the content of the RichText string but they removed it for now because apparently it broke stuff

1 Like

The typewritter works, and it uses Roblox’s new TextLabel property.

I just want to know how I can eliminate RichText from the label, also that doesn’t work with RichText.

That is what MaxVisibleGraphemes is. It is a modifiable value that shows you what the content is.

The link you posted has an example that can remove RichText tags for you

local text = 'Hello! I am <font color="#FFA500">Haran</font>. What is your name?'

local function removeTags(str)
	str = str:gsub("<br%s*/>", "\n")
	return (str:gsub("<[^<>]->", ""))
end

local displayText = removeTags(text)
print(displayText)
> Hello! I am Haran. What is your name?
9 Likes

You can make a variable containing the same text but without any tags. Then apply the one with tags to the text but loop through the one without tags and play the type sound.