The loop runs all the way but doesn't print stop.
part = script.Parent clicked = false part.MouseButton1Click:connect(function() ---------------Debounce------------------ if clicked == false--Checks if clicked is false(Which it should be,because it already been set false) then clicked = true-- Since it false it will turn it true(so we know it's alread been clicked) end ----------------Fade Out------------------ for fo = 0,1,0.1 do wait(0.1) part.BackgroundTransparency = fo part.TextTransparency = fo if fo == 1 then print("stop") part.Active = false end end end)
This is due to how lua (and moreso any computer language that uses floating point values or doubles) handles decimals. When you do a for loop like that, you don't end up with exactly one. You end up with what looks like 1, but when you compare it to 1 you find it's less than 1!
The best way to avoid this is when you're doing for loops like this, have the loop go from 0 to 10 and every time you want to use i
just divide it by 10 and you have a number between 0 and 1 while being precise.