local tbox = script.Parent.t4 local nbox = script.Parent.t5 local name = script.Parent.PName local qt = script.Parent.Quote name.Text = "Unknown" wait() qt.Text = "H" wait() qt.Text = "He" wait() qt.Text = "Hel" wait() qt.Text = "Hell" wait() qt.Text = "Hello" wait() qt.Text = "Hello t" wait() qt.Text = "Hello th" wait() qt.Text = "Hello the" wait() qt.Text = "Hello ther" wait() qt.Text = "Hello there" wait() qt.Text = "Hello there." wait() qt.Text = "Hello there. T" wait() qt.Text = "Hello there. Th" wait() qt.Text = "Hello there. The" wait() qt.Text = "Hello there. The n" wait() qt.Text = "Hello there. The na" wait() qt.Text = "Hello there. The nam" wait() qt.Text = "Hello there. The name" wait() qt.Text = "Hello there. The names" wait() qt.Text = "Hello there. The names T" wait() qt.Text = "Hello there. The names To" wait() qt.Text = "Hello there. The names Tom" wait() qt.Text = "Hello there. The names Tom." wait() name.Text = "T" wait() name.Text = "To" wait() name.Text = "Tom"
Any idea?
I would say use string.sub
this should take the string into parts for example:
print( string.sub("Hi Mom!", 1, 4) ) print( string.sub("Hi Mom!", 2) )
would output: "Hi M" "i Mom"
For your problem I would suggest using a for loop like this:
v = string.len("Hello there. The name's Tom.") for i = 1, v do qt.text = string.sub("Hello there. The name's Tom.", 1, i) wait() end
(string.len
just counts the characters in a string)
That should work as a more compact way.
function animatetext(obj,text) for i = 1, #text do obj.Text = text:sub(1,i) wait() end end) local qt = script.Parent.Quote local name = script.Parent.PName animatetext(name, 'Tom') animatetext(qt, "Hello there, the name's Tom")