01 | local tbox = script.Parent.t 4 |
02 | local nbox = script.Parent.t 5 |
03 | local name = script.Parent.PName |
04 | local qt = script.Parent.Quote |
05 |
06 | name.Text = "Unknown" |
07 | wait() |
08 | qt.Text = "H" |
09 | wait() |
10 | qt.Text = "He" |
11 | wait() |
12 | qt.Text = "Hel" |
13 | wait() |
14 | qt.Text = "Hell" |
15 | wait() |
Any idea?
I would say use string.sub
this should take the string into parts for example:
1 | print ( string.sub( "Hi Mom!" , 1 , 4 ) ) |
2 | print ( string.sub( "Hi Mom!" , 2 ) ) |
would output: "Hi M" "i Mom"
For your problem I would suggest using a for loop like this:
1 | v = string.len( "Hello there. The name's Tom." ) |
2 |
3 | for i = 1 , v do |
4 | qt.text = string.sub( "Hello there. The name's Tom." , 1 , i) |
5 | wait() |
6 | end |
(string.len
just counts the characters in a string)
That should work as a more compact way.
01 | function animatetext(obj,text) |
02 | for i = 1 , #text do |
03 | obj.Text = text:sub( 1 ,i) |
04 | wait() |
05 | end |
06 | end ) |
07 |
08 | local qt = script.Parent.Quote |
09 | local name = script.Parent.PName |
10 |
11 | animatetext(name, 'Tom' ) |
12 | animatetext(qt, "Hello there, the name's Tom" ) |