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
6 years ago
Edited 6 years ago
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?

2 answers

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

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.

0
Alright, I've tested it and it works. Have fun! robloxianmirror 57 — 6y
Ad
Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago
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")

Answer this question