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

Is there a faster way to do this?

Asked by 10 years ago

Is there a faster way of changing text rather than doing it the way below?

TextBox.Text = "W"
wait(.05)
TextBox.Text = "We"
wait(.05)
TextBox.Text = "Wel"
wait(.05)
TextBox.Text = "Welc"
wait(.05)
TextBox.Text = "Welco"
wait(.05)
TextBox.Text = "Welcom"
wait(.05)
TextBox.Text = "Welcome"

2 answers

Log in to vote
0
Answered by 10 years ago

Yes, there is, and it requires using a for loop;

--

Edited, thanks BlueTaslem for pointing that all out to me

local Welcome = "Welcome" --Heres our string

for i = 1, #Welcome do --Heres our for loop
TextBox.Text = Welcome:sub(1,i)) --It is going to doing something like this each 0.05 seconds; w, we, wel, welc, welco, welcom, welcome
wait(.05) --Waits 0.05 seconds before putting the next character
end --The end for the for loop

Hope this helped!

0
The `tostring` is redundant, unnecessary. You have the parameters of string.sub backwards! `1, i` not `i, 1`! In addition, you can use `Welcome:sub` instead of `string.sub(Welcome,` BlueTaslem 18071 — 10y
0
Thanks! Can you breakdown tostring(string.sub(Welcome,i,1)) for me? GianniKun 40 — 10y
0
"substring" means a part of a string. The first one is where to start, the second one is where to end. So `1, i` would be the first `i` characters. Note that the answer has them backwards: it should be written `1, i` not `i, 1` BlueTaslem 18071 — 10y
Ad
Log in to vote
-2
Answered by 10 years ago

Yes just do it WEL WELCO WELCOME

try this that what i did

Answer this question