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

GUI fade script?

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

1 comment

0

Output? Is it instantly going from invisible to black, or is it not even changing?

2 answers

✓ Accepted answer

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.

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

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