Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a faster way to do this?

dialog = script.Parent

dialog.Text = "H"
wait(0.1)
dialog.Text = "He"
wait(0.1)
dialog.Text = "Hey"
wait(0.1)
dialog.Text = "Hey "
wait(0.1)
dialog.Text = "Hey y"
wait(0.1)
dialog.Text = "Hey yo"
wait(0.1)
dialog.Text = "Hey you"
wait(0.1)
dialog.Text = "Hey you,"
wait(0.1)
dialog.Text = "Hey you, "
wait(0.1)
dialog.Text = "Hey you, y"
wait(0.1)
dialog.Text = "Hey you, ye"
wait(0.1)
dialog.Text = "Hey you, yea"
wait(0.1)
dialog.Text = "Hey you, yea "
wait(0.1)
dialog.Text = "Hey you, yea y"
wait(0.1)
dialog.Text = "Hey you, yea yo"
wait(0.1)
dialog.Text = "Hey you, yea you"
wait(0.1)
dialog.Text = "Hey you, yea you!"
wait(0.1)
dialog.Text = "Hey you, yea you!"
wait(0.1)
dialog.Text = "Hey you, yea you! "
wait(0.1)
dialog.Text = "Hey you, yea you! D"
wait(0.1)
dialog.Text = "Hey you, yea you! Do"
wait(0.1)
dialog.Text = "Hey you, yea you! Do "
wait(0.1)
dialog.Text = "Hey you, yea you! Do y"
wait(0.1)
dialog.Text = "Hey you, yea you! Do yo"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you "
wait(0.1)
dialog.Text = "Hey you, yea you! Do you r"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you re"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you rem"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you reme"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remem"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you rememb"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remembe"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember "
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember a"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember an"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember any"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anyt"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anyth"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anythi"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anythin"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anything"
wait(0.1)
dialog.Text = "Hey you, yea you! Do you remember anything?"
wait(0.1)

What I'm trying to do is make it so all the text doesn't appear at once, but adds one letter at a time. If you don't get what I mean, it's basically like the Pokemon text, and I was wondering if there was a faster way to do this, or do I have to write each one, one at a time? Thanks for the help!

3 answers

✓ Accepted answer

##Solution

Of course there's an easier way to do it. You would want to use string manipulation and a for loop to change the text of the TextLabel (or other object). So to set it up, you want to have a variable set to the message you want. You would then want a numeric for loop which by default adds 1 to the variable i each time it loops through. When setting the value of the text label, you will want to use the sub function of strings to get the text from point a to point b basically.


##Final Script

local Message = "Hey you, yea you! Do you remember anything?" --We set the variable here, we will be able to reference it later in the script.
local dialog = script.Parent

for i=1, Message:len() do --The :len() method on Message is what will get how many characters are in the string you defined above. So everything between 1 and however long the string is, the for loop will execute.
    dialog.Text = Message:sub(1,i) --i is basically a variable we defined when creating the for loop, i could be placement or any other means of defining the variable you want. The script is now getting all the characters between 1 and the i variable at the time the loop is executing.
    --1 is added to i automatically in a for loop.
    wait(.1) --This is the wait you wanted.
end --With all for loops, you need an end.

######Hopefully this answered your question, if it did do not forget to hit the accept answer button. If you have any questions, feel free to comment below.

1 comment

0

Thank you so much! And thank you even more for explaining everything in the script!

Yep!

local text = "Hey you, yea you! Do you remember anything?"

for i = 1, #text do -- #text is length of text
	dialog.Text = text:sub(1, i) -- text:sub(1, i) is only the first through i letters in the string
	wait(.1)
end

5 comments

0

That didn't seem to work?

0

Wow, never refreshed my page xd

0

My whole life is a lie, thank you! Fixed

0

YOU LIAR

0

Thank you soooo much! This makes my life a whole lot easier :)

You could use the numeric for loop.

local word = "Hey you, yea you! Do you remember anything?"
dialog = script.Parent
for i=1, string.len(word) do -- run the loop the amount of characters there are
	dialog.Text = string.sub(word,1,i)
	wait(0.1)
end

1 comment

0

where's shawny's love

This discussion is preserved as it was. New answers, comments, and votes are closed.