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

How do I fade in and fade out text labels?

In my intro for my game I want phrases to appear across a black screen 1 at a time. I want "No name..." in the top left corner "no memories..." in the center and "Only the knowledge that you want to get out" strewn across the bottom. Can someone teach me how to fade in and fade out text labels, or at least explain it? Giving me a code it's would be awesome, but I want to learn how to do it

3 answers

You can't really fade text, but this will fade the background.

local TextToFade = --Insert the frame you want to fade here.
for transparency = 1, 100 do
	TextToFade.BackgroundTransparency = transparency
	wait()
end

6 comments

0

You can fade text using TextTransparency.

0

oh didnt know that

0

Just put this script in all the textlabel’s you want to fade: local texttofade = script.Parent for i = 1,0,-0.1 do texttofade.TextTransparency = i wait(0.5) end

0

pro tip: if you want fading smooth use

0

pro tip: if you want fading smooth use: local RS = game["Run Service"].RenderStepped; and replace wait() with RS:wait();

0

pro tip: if you want fading smooth use: local RS = game["Run Service"].RenderStepped; and replace wait() with RS:wait();

To make something fade in and out, you need to use something called for. For is a way to run a command multiple times, kind of like while wait() do. For example, this repeats the command print 10 times:

for i=1, 10 do   	
   print("Repeat!")
end

To use for to fade in a gui element such as a Frame, you could do this:

local Frame = script.Parent.Frame
-- Fading in
for i = 1,100 do
Frame.BackgroundTransparency = Frame.BackgroundTransparency - 0.01
wait()
end
wait(3)
--Fading out
for i = 1,100 do
Frame.BackgroundTransparency = Frame.BackgroundTransparency + 0.01
wait()
end

For text:

local text = script.Parent.TextLabel
for i = 1,100 do
text.TextTransparency = text.TextTransparency - 0.01
wait()
end
wait(3)
for i = 1,100 do
text.TextTransparency = text.TextTransparency + 0.01
wait()
end

Hope this helped!

1 comment

0

You could just use the i variable, I just think it is faster typing i then txt.TextTransparency and stuff

Put this script into any textlabel to fade, the script will do everything!

local texttofade = script.Parent

for i = 10,0,-0.1 do
texttofade.TextTransparency = i
wait(0.5)
end

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