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 10 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.

b = script.Parent
b.MouseButton1Click:connect(function()
for n = 0,1,0.1 do
            wait(0.1)
    b.BackgroundTransparency =n
    b.TextTransparency = n
if n == 1
    then
    break
end
        for i = 1,0,-0.1 do
    wait(0.1)
    b.BackgroundTransparency =i
    b.TextTransparency = i
if i == 0 then
    break
end
        end
end
end)


1 answer

Log in to vote
1
Answered by 10 years ago
b = script.Parent
debounce = false
b.MouseButton1Click:connect(function()
    if not debounce then
        debounce = true
        for n = 0,1,0.1 do
                    wait(0.1)
            b.BackgroundTransparency =n
            b.TextTransparency = n
        end
        wait(120)
        for i = 1,0,-0.1 do
            wait(0.1)
            b.BackgroundTransparency =i
            b.TextTransparency = i
        end
        debounce = false
    end
end)



Something of this sort.

Ad

Answer this question