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

How to make words that type?

Like I wanted to make something on my TextLabel that typed for example "Welcome to my place" but it typed out every letter to make the word. Can anyone help me?

1 answer

text = "Welcome to my place" --Some text to be "typed out" on the text label
textlabel =  --Place TextLabel object here

for i = 1, #text do
	textlabel.Text = string.sub(text, 1, i)
	wait(.1)
end

So, we make some text to be typed out. We create a variable for the TextLabel object. Then, we create a numeric for loop, running code for each character in the text. Each time we loop, we add one character to the TextLabel's text. string.sub returns a substring from the text between the second and third arguments. For example:

text = "Hello world!"
print(string.sub(text, 1, 5))

That prints out "Hello". A substring between "i" and "i" would be "W", "We", "Wel", "Welc"... and so on. We then wait for a 10th of a second between iterations to simulate realistic typing speed.

1 comment

2

It's a bad idea to use (i, i) -- you should use (1, i). Also remember how much cuter text:sub(1, i) is than string.sub(text, 1, i)!

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