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

How do I create a typewriter effect for a GUI's text?

Asked by 8 years ago

I'm assuming I would use a pairs loop? I need it to look like this and don't know how to make it work:

L, Li, Lik, Like, Like , Like T, Like Th, Like Thi, Like This, Like This.

0
I'm not able to answer, but experiment. As far as I'm concerned, use for i=1,the_number_of_characters_in_your_sentence do thing.Text = string.sub(the_text_variable,1,+1) unmiss 337 — 8y
0
Not positive but I think you do pairs and then use math maybe like l+i but in not sure and I can't test it cuz I'm on mobile. iSvenDerp 233 — 8y

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

You have to use a numerical for loop, then use string.subfrom a preset target string!

local str = "Like this." --The target string

--Iterate for the amount of characters the string has.
for i = 1,#str do
    --Use string .sub with the 'i' value.
    local substr = str:sub(1,i)
    wait(.1)
end
0
I added a line to change the text to the substr but it immediately showed str's value. Can you fix this? SchonATL 15 — 8y
0
I added a wait(: Goulstem 8144 — 8y
0
Works great, thanks! SchonATL 15 — 8y
Ad
Log in to vote
0
Answered by
drahsid5 250 Moderation Voter
8 years ago

This is fairly simple.

Firstly,

define all your text strings

textID= {"Test"}

Then, make a for loop to type it out

for i=1, string.len(textID[i]) do
            script.Parent.UI.TextBack.txt.Text = (script.Parent.UI.TextBack.txt.Text..string.sub(textID[1],i,i) ) --Put your gui here
            game:GetService("RunService").RenderStepped:wait()
       end

So it should look like this:

textID= {"Test"}

for i=1, string.len(textID[i]) do
            script.Parent.UI.TextBack.txt.Text = (script.Parent.UI.TextBack.txt.Text..string.sub(textID[i],i,i) )
            --game:GetService("RunService").RenderStepped:wait()
       end

Answer this question