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

Loop not stopping with break,why?

Asked by 11 years ago

I want the surface gui button fade out when clicked and the wait about 2 minutes then fade in,but it just keeps looping for a long time.

01b = script.Parent
02b.MouseButton1Click:connect(function()
03for n = 0,1,0.1 do
04            wait(0.1)
05    b.BackgroundTransparency =n
06    b.TextTransparency = n
07if n == 1
08    then
09    break
10end
11        for i = 1,0,-0.1 do
12    wait(0.1)
13    b.BackgroundTransparency =i
14    b.TextTransparency = i
15if i == 0 then
16    break
17end
18        end
19end
20end)

1 answer

Log in to vote
1
Answered by 11 years ago
01b = script.Parent
02debounce = false
03b.MouseButton1Click:connect(function()
04    if not debounce then
05        debounce = true
06        for n = 0,1,0.1 do
07                    wait(0.1)
08            b.BackgroundTransparency =n
09            b.TextTransparency = n
10        end
11        wait(120)
12        for i = 1,0,-0.1 do
13            wait(0.1)
14            b.BackgroundTransparency =i
15            b.TextTransparency = i
16        end
17        debounce = false
18    end
19end)

Something of this sort.

Ad

Answer this question