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

"Typewriter" effect on a TextLabel?

What I'm trying to do is something like this.

--On the TextLabel
W
We
Wel
Welc
Welco
Welcom
Welcome
Welcome 
Welcome t
Etc. etc...

I have two scripts in which I have, one which changes the text, and one which makes the effect, but I don't know how to incorporate both, or at least make the 2nd script more efficient, and able so I can add as many messages I want without having to do much scripting.

Changes the text

local sign = script.Parent
local text= { --Titles
    "Welcome to ______ trailer park.";
    "Want to serve our park?";
    "Join one of the service groups!";
}
while wait() do
	for i,r in ipairs(text) do
	        sign.Text = titles[i]
	        wait(5)
        end
end

Typewriter effect.

local MessageA = "Welcome to ______ trailer park."
local MessageB = "Want to serve our park?"
local MessageC = "Join one of the service groups!"

local text = script.Parent

while wait() do
	for i=1, MessageA:len() do 
	    text.Text = MessageA:sub(1,i)
	    wait(.1)
	end
	wait(3)
	for i=1, MessageB:len() do 
	    text.Text = MessageB:sub(1,i)
	    wait(.1)
	end
	wait(3)
	for i=1, MessageC:len() do 
	    text.Text = MessageC:sub(1,i)
	    wait(.1)
	end
	wait(3)
end

Thank you

1 answer

✓ Accepted answer

You can simply use a for loop to iterate through the text table and then have a second for loop in the first loop create the type-writer effect, like so:

local sign = script.Parent
local Msg= { --Titles
    "Welcome to ______ trailer park.";
    "Want to serve our park?";
    "Join one of the service groups!";
}
local text = script.Parent
while wait() do
	for _, m in pairs(Msg) do --Iterate through the text table
		for i = 1, m:len() do --Have a second loop inside the first loop to create the effect
			text.Text = m:sub(1, i)
			wait(0.1) --How long it waits between each letter
		end
		wait(5) --How long it waits between each text
	end
end

Hope this helped!

1 comment

1

Just a little tip, you don't need ; you can also use ,. Love your guns btw!

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