It’s necessary that you should put an if statement in a while loop like this
--Insert your first 4 lines of script here
while wait(0.01) do
if MainFrame.BackgroundTransparency <= 0 then
MainFrame.BackgroundTransparency += 0.01
elseif MainFrame.BackgroundTransparency >= 10 then
MainFrame.BackgroundTransparency -= 0.01
end
end
Actually, you could use a For Loop, or TweenService. You can read more about loops here, and Tweens here.
Here is the solution:
local MainFrame = script.Parent
local LoadingGui script.Parent.Parent
wait(2)
for i=0, 1, -0.01 do
MainFrame.BackgroundTransparency -= 0.01
wait(0.01)
end
You can also use TweenService. Here is a (better) example with TweenService:
local MainFrame = script.Parent
local LoadingGui script.Parent.Parent
wait(2)
game:GetService("TweenService"):Create(MainFrame, TweenInfo.new(1), {Transparency = 1}):Play()