Camera fade not working?

Trying to make a main menu (which I have successfully done), the problem is, I tried to make it so that when the player clicks the play button, it has this cool transition where the camera fades to black, then fades back to where everything is visible.
Here’s the script:

local player = game.Players.LocalPlayer
local char = player.CharacterAdded
local mouse = player:GetMouse()
local cam = game.Workspace.CurrentCamera

local defaultcf = cam.CFrame
local view = 150
local blur = game.Lighting.Blur

blur.Size = 6
game.Workspace.AMBIENCE:Stop()
function updatecam()
cam.CFrame = game.Workspace.MenuCam.CFrame

end
local transframe = game.StarterGui.TRANSITION.Frame

game:GetService(“RunService”).RenderStepped:Connect(updatecam)

script.Parent.Frame.PLAY.MouseButton1Click:Connect(function()
local transframe = game.StarterGui.TRANSITION.Frame
wait(.2)
blur.Size = 0
game.Workspace.MENUMUSIC:Stop()
game.Workspace.AMBIENCE:Play()

while true do
wait(.01)
transframe.BackgroundTransparency = transframe.BackgroundTransparency - .01

  if transframe.BackgroundTransparency == 0 then
  	break
  end

end

wait(.5)
cam.CameraType = Enum.CameraType.Custom
script.Parent.Frame:Destroy()

while true do
wait(.01)
transframe.BackgroundTransparency = transframe.BackgroundTransparency + .01

  if transframe.BackgroundTransparency == 1 then
  	break
  end

end

script:Destroy()
end)

Screenshot_368

My suggestion:
I suggest using tween service instead of while loops.

Sidenote: You don’t need to constantly CFrame the camera with RenderStep. You can simply just set it once (just make sure the player has loaded, etc).

Solution to your issue:

As for the issue, I’m going to guess it due to the while loops. Although you do have an if statement thats suppose to break the loop, its only checking if the background transparency is exactly equal to 1 or 0. Since your adding and subtracting by 0.1 each 0.1 seconds it won’t exactly reach 0 or 1 (it may get close like 1.01 or something but thats still not 1).

What you need to do is change the == statements to <= (for the first loop) and >= (for the second loop). I highly advise you use tween service for both the camera tweening and fade effect.

Note I haven’t looked at the rest of your code since I’m on mobile and its hard to see, so there may also be other issues with your code that I haven’t noticed.