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

What would I do to make this script shorter?

I remember seeing something on wiki where you could find the text length of a string, I don't remember it clearly, so here is an example of what I have

script.Parent.Text = "g"
wait(1)
script.Parent.Text = "ge"
wait(1)
script.Parent.Text = "get"
----ETC.-------

1 answer

✓ Accepted answer

We can get pieces of a string, called substrings using the sub method:

msg = "Hello there"
script.Parent.Text = msg:sub(1,5) -- get characters 1 to 5 (inclusive)

There are #msg characters in msg (# is a unary operator for string length as well as table length) so a loop could look like this:

for i = 1, #msg do
	script.Parent.Text = msg:sub(1, i)
	wait(1)
end

1 comment

0

I would like to add that you can also use the len() method to get the LENgth of a string.

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