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

how can i improve my fading text script to save performance ?

Hello, I'm trying to slowly fade a text with this script and slowly make it visible again. Unfortunately this script is not very elegant and a bit long. Can anyone help me to shorten or improve it?

while true do	
	script.Parent.TextTransparency = 0.05
	wait(0.2)
	script.Parent.TextTransparency = 0.1
	wait(0.2)
	script.Parent.TextTransparency = 0.15
	wait(0.2)
	script.Parent.TextTransparency = 0.2
	wait(0.2)
	script.Parent.TextTransparency = 0.25
	wait(0.3)
	script.Parent.TextTransparency = 0.3
	wait(0.2)
	script.Parent.TextTransparency = 0.35
	wait(0.2)
	script.Parent.TextTransparency = 0.4
	wait(0.2)
	script.Parent.TextTransparency = 0.45
	wait(0.2)
	script.Parent.TextTransparency = 0.5
	wait(0.2)
	script.Parent.TextTransparency = 0.5
	wait(0.2)
	script.Parent.TextTransparency = 0.45
	wait(0.2)
	script.Parent.TextTransparency = 0.4
	wait(0.2)
	script.Parent.TextTransparency = 0.35
	wait(0.2)
	script.Parent.TextTransparency = 0.3
	wait(0.2)
	script.Parent.TextTransparency = 0.25
	wait(0.2)
	script.Parent.TextTransparency = 0.2
	wait(0.2)
	script.Parent.TextTransparency = 0.15
	wait(0.2)
	script.Parent.TextTransparency = 0.1
	wait(0.2)
	script.Parent.TextTransparency = 0.05
	wait(0.2)
	script.Parent.TextTransparency = 0
	wait(0.2)
	print("finished")
	wait(0.2)
end

1 answer

✓ Accepted answer

You can use a for loop and let the TextTransparency be the "counting" value for instance

for NewTransparency = 0,0.5,0.05 do
	script.Parent.TextTransparency = NewTransparency
end

The "0" is the Start value, the 0.5 is the End value and the ".05" is the incrementing value.

And if you want to do it the other way just switch the Start value and the End value.

1 comment

0

Thank you so much ^^

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