I've made 2 LocalScripts that serve as Fade In and Fade Out effects for my ScreenGui:
--Fade Out
local Screen = script.Parent
Screen.BackgroundTransparency = 0
Screen.Visible = true
for Trnsprncy = 0, 1, 0.1 do
wait(0.01)
print(Trnsprncy)
Screen.BackgroundTransparency = Trnsprncy
end
Screen.Visible = false
--Fade In
local Screen = script.Parent
Screen.BackgroundTransparency = 1
Screen.Visible = true
for Trnsprncy = 1, 0, -0.1 do
wait(0.01)
print(Trnsprncy)
Screen.BackgroundTransparency = Trnsprncy
end
The Fade Out script works as intended, simple and smooth, however the Fade In script decreases as follows (Printed in the Output):
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
1.3877787807814e-16
Because of the exaggerated number at the end, the Frame doesn't go completely black and instead displays as if the BackgroundTransparency was "1"
I just want to know why does this happen specifically when decreasing the variable and how can I fix the For Loop.

1 comment
The Tweening method works flawlessly, however the For Loop method errors at line 27: "Attempt to compare number with boolean". I'd consider this question solved so thank you!