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

GUI fade script?

Asked by
Zyleak 70
9 years ago

The 1st part works but the 2nd does not.

for i = 0, 1, 0.01 do
        Frame.BackgroundTransparency = Frame.BackgroundTransparency +i
        wait(0.05)
end
wait(2)
for i = 1, 0, 0.01 do
        Frame.BackgroundTransparency = Frame.BackgroundTransparency -i
        wait(0.05)
end
0
Output? Is it instantly going from invisible to black, or is it not even changing? LevelKap 114 — 9y

2 answers

Log in to vote
0
Answered by
Wizzy011 245 Moderation Voter
9 years ago

The Problem

If you look at your second for loop, you have 3 parameters:

-The first being the starting value

-The second being the end value

-The third being the increments the for loop steps using

The problem with your values is, your third parameter doesn't actually make sense. If you kept adding 0.01 to 1, you'd end up with 1.01, 1.02, 1.03..... and so on, my point being you'd never arrive at 0.

The solution

All you need to do is change your stepping value to -0.01and remove the minus sign from line 7. Your script should then function as you want it to.

Ad
Log in to vote
0
Answered by
LevelKap 114
9 years ago

Ah, i think it's because of this line:


for i = 1, 0, 0.01 do


You told the loop to start from 1, end at 0, then count up by 0.0.1 Logically, 1 can never get to zero by counting upwards. Try changing 0.01 to -0.01

Answer this question