I’m trying to make a fading black screen appear with this code:
local Players = game:GetService("Players")
local HasBegan = RS:WaitForChild("HasBegan")
local Intro = script.Parent
HasBegan:GetPropertyChangedSignal("Value"):Connect(function()
if HasBegan.Value == false then
return
else
Intro.Visible = true
for i = 1,0,-0.01 do
Intro.BackgroundTransparency = i
print(i)
wait(0.03)
end
end
end)
It works fine up until the increment reaches around 0.12 after that it breaks and doesn’t completely reach the goal of 0.
I recommend using TweenService instead. Although, if you do want to stick with the loop, just set the UI’s transparency after the loop to end goal.
ex: game:GetService("TweenService"):Create(Intro,TweenInfo.new(2,Enum.EasingStyle.Linear),{BackgroundTransparency = 0}):Play()
It’s just another example of Roblox’s floating point errors. No need to worry. If you wanted to avoid this, you can switch to whole numbers, or do it via the above.