Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a far more simpler way to do this?

Asked by
Foridex 46
7 years ago
Edited 7 years ago
01local tbox = script.Parent.t4
02local nbox = script.Parent.t5
03local name = script.Parent.PName
04local qt = script.Parent.Quote
05 
06name.Text = "Unknown"
07wait()
08qt.Text = "H"
09wait()
10qt.Text = "He"
11wait()
12qt.Text = "Hel"
13wait()
14qt.Text = "Hell"
15wait()
View all 58 lines...

Any idea?

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I would say use string.sub this should take the string into parts for example:

1print( string.sub("Hi Mom!", 1, 4) )
2print( string.sub("Hi Mom!", 2) )

would output: "Hi M" "i Mom"

For your problem I would suggest using a for loop like this:

1v = string.len("Hello there. The name's Tom.")
2 
3for i = 1, v do
4qt.text = string.sub("Hello there. The name's Tom.", 1, i)
5wait()
6end

(string.len just counts the characters in a string)

That should work as a more compact way.

0
Alright, I've tested it and it works. Have fun! robloxianmirror 57 — 7y
Ad
Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
7 years ago
01function animatetext(obj,text)
02       for i = 1, #text do
03              obj.Text = text:sub(1,i)
04              wait()
05       end
06end)
07 
08local qt = script.Parent.Quote
09local name = script.Parent.PName
10 
11animatetext(name, 'Tom')
12animatetext(qt, "Hello there, the name's Tom")

Answer this question