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

How do I make a textlabel text change by letter and not come in all at once?

Asked by 7 years ago

is this how you have to do it? script.Parent.Text = ('H') wait(0.2) script.Parent.Text = ('He') wait(0.2) script.Parent.Text = ('Hel') wait(0.2) script.Parent.Text = (Hell') wait(0.2) script.Parent.Text = ('Hello') wait(0.2)

3 answers

Log in to vote
1
Answered by
jotslo 273 Moderation Voter
7 years ago
Edited 7 years ago

One method that you could use to achieve this is to create a for loop from 1 - length of string and display the first n letters of the string using string.sub()

Example:

local text = "Hello"

for i = 1, #text do
    TextLabel.Text = text:sub(1, i)
    wait(.2)
end

I hope this helps!

Ad
Log in to vote
0
Answered by 7 years ago

I guess that's one way to do it, but there's an easier way using String.sub and a for loop.


Using the for loop, you will use the length of the string to get the letters;

local str = "The text you want."
local textLabel = script.Parent -- Assuming this script is inside a TextLabel.

for i = 1, #str do -- In this case, it will start at 1 (T) and end at 18 (the period).
    textLabel.Text = str:sub(1, i)
    wait(.5) -- The longer you make the wait, the longer it will take to go to the next letter.
end
0
You literally copied what I posted jotslo 273 — 7y
Log in to vote
-1
Answered by 7 years ago

while true do is optional Must be in a local script Local Script must be in TextLabel or TextButton

while true do
wait(math.random(1,2))
script.Parent.Text = 'H'
wait(math.random(1,2))
script.Parent.Text = 'He'
wait(math.random(1,2))
script.Parent.Text = 'Hel'
wait(math.random(1,2))
script.Parent.Text = 'Hell'
wait(math.random(1,2))
script.Parent.Text = 'Hello'
wait(math.random(5,10))
script.Parent.Text = ' '
end)
0
Well I really wanted a quicker way to do what I was doing but you are just doing what I was doing but in a while true do function and my function is an ontouchedpart function and you are just making the waits longer and using math.random. Please don't answer if someone has already posted a better one DreamSkyHigh 30 — 7y

Answer this question