How do I loop through a string and insert letters singularly into a textlabel?

I have a notification system that creates a textlabel, and sets the text to whatever the first argument of the function is (a string), the other arguments are textcolor and notificationType (failed action, success, error). Anyways, what I am hoping to achieve, is when a notification is received, the text is inserted into the text label one letter at a time, to create an effect similar to typing out a sentence on a keyboard. The funny thing is I’ve actually done this before, and I can’t remember how I did it!

local label = script.Parent

local strings = "abcdefghijklmnopqrstuvwxyz"

task.wait(3)

for count = 1, strings:len() do
	task.wait(0.5)
	label.Text..=strings:sub(count, count)
end

Here’s an example script.

Here’s what it looks like in action.

https://gyazo.com/bbdc2b62d748e362aca2b9af46dd044f

You’d likely need to play around with the task.wait(0.5) part until your get the desired effect.

1 Like