How does switching camera work?

when the part resembling camera is far away it looks like the script uses current camera because it locks on current camera position

HERE IS THE MENTIONED SCRIPT:

--------Menu Camera Script
local cam = workspace.CurrentCamera
local player = game.Players.localPlayer

repeat wait() until player.Character

wait(1)
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = workspace.menucam.CFrame

COULD SOMEONE EXPLAIN ME WHY AND HOW IT WORKS ?

local cam = workspace.CurrentCamera
local player = game.Players.localPlayer

Setting variables for the camera that the player uses and the player instance.


repeat wait() until player.Character

Wait until the character model is loaded in the game to avoid the code running before parts have even loaded in.


cam.CameraType = Enum.CameraType.Scriptable

Disabling the built-in camera controls that Roblox gives you, letting you edit the camera properties freely.


cam.CFrame = workspace.menucam.CFrame

Align the camera to the menucam instance in the workspace, making the player see from that perspective.