Getting length of a string

Hello DevForum users!
I am creating a Type Writter effect but i encoutered a big issue.

  1. What do you want to achieve? Keep it simple and clear!
    I want to delete anything in the string that is rich text, or ignore it so i can play the right amount of sounds my type writter effect needs to play.

  2. What is the issue? Include screenshots / videos if possible!
    I dont know any method that is not TOO complicated!

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    Searching here in DevForum, using text or string.sub (both get the perfect amount of characters from a string so yeah didnt work)

Current Code!

function Write(Text: string, Label: TextLabel)
	if not Text or not Label then return end
	TextLabel.MaxVisibleGraphemes = 0

	for i = 1,string.len(Text) do
		Label.Text = Text
		script.Pop.PlaybackSpeed = math.random(95,115) / 100
		script.Pop:Play()
		Label.MaxVisibleGraphemes = i
		task.wait(0.025)
	end
end
function Write(Text: string, Label: TextLabel)
	if not Text or not Label then return end
	local Plain = Text:gsub("<[^>]->", "")
	Label.MaxVisibleGraphemes = 0
	for i = 1,#Plain do
		Label.Text = Text
		script.Pop.PlaybackSpeed = math.random(95,115)/100
		script.Pop:Play()
		Label.MaxVisibleGraphemes = i
		task.wait(0.025)
	end
end

3 Likes

Thank you a lot, looks like it works, how does that code work?
I know what string.gsub does but, what is that key combination?

It’s being used as a type of filter or a manual-made filter.
It’s removing patterns that match what is in <…>, which are the rich text tags in this case.

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