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

Loop not stopping with break,why?

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

✓ Accepted answer
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.

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