How do i use richtext while using string.sub

hi so bassicly i learned about rich text in roblox ofc, but the problem is that when i tried using type writer effect it started typing out < B >hi</ B> instead of just having Hi be bold or colored red or stuff like that, how could i overcome this?

You should use the TextLabel.MaxVisibleGraphemes property.
It is made specifically for a typewriter effect.
https://create.roblox.com/docs/reference/engine/classes/TextLabel#MaxVisibleGraphemes

I would also suggest you read this.
https://create.roblox.com/docs/ui/animation#typewriter-effect

Hi! @Brambes230605 was faster than me, but i’ll add to clarify.
In case of typewriter, to out text to Gui, you can use MaxVisibleGraphemes property:

task.wait(1)

local Text = "<b>Hello World!</b>"
script.Parent.Text = Text

for i = 1, #Text do
	script.Parent.MaxVisibleGraphemes = i
	task.wait(0.1)
end

This set amount of visible actual text characters.
But if you need actually sub string for something other, probably there’s no elegant way to remove rich formatting from pre-made text.
Edit: Okay i just read that like about typewriter effect in docs, and yes, there is elegant way to remove rich formatting, sorry for lie.

thank you guys for helping thought it was gonna be some like mega ultra complicated thing or smth

yo one more thing, like bassicly it also counts the <font> so it akwardly stays there for like 3 more seconds then moves on to the next, hope you understand

You can use TextLabel.ContentText instead of TextLabel.Text to get the number of characters.
It’s important to note that #string does not actually return the number of characters. It returns the size of the string in bytes, which matches the character count in most cases but can be inaccurate when using emojis. For example, #"😊" would return 4, even though there is only 1 character.

To correctly get the length of a string, you should use utf8.len. So, to accurately get the length of a string with rich text in a TextLabel, you can do:

local stringLength = utf8.len(TextLabel.ContentText)

Yo thanks, Sorry for the late response i was taking a break of roblox