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

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

Asked by 3 years ago

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

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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.

0
Thank you so much ^^ pinopeltzi 7 — 3y
Ad

Answer this question