When you click "z" it is supposed to zoom in This is my first time working with the camera
local zoomMin = 70 -- FOV default
local zoomMax = 40 -- FOV zoom in
local zoomFrames = 10 -- Larger number = slower zoom speed
local zoomWalkSpeedMultiplier = 0.5 -- Slows character down by this factor upon zooming
local Cam = game.Workspace.CurrentCamera
local canZoom = false
playerPlayer = game.Players.LocalPlayer
playerCharacter = playerPlayer.Character
playerHumanoid = playerCharacter.Humanoid
function zoomIn()
-- print[[zoomIn()]]
isZoomed = true
playerHumanoid.WalkSpeed = playerHumanoid.WalkSpeed * zoomWalkSpeedMultiplier
for i = 1, zoomFrames do
Cam.FieldOfView = Cam.FieldOfView + (zoomMax - Cam.FieldOfView)/3
wait()
end
Cam.FieldOfView = zoomMax
end
function zoomOut()
-- print[[zoomOut()]]
isZoomed = false
playerHumanoid.WalkSpeed = playerHumanoid.WalkSpeed
for i = 1, zoomFrames do
Cam.FieldOfView = Cam.FieldOfView + (zoomMin - Cam.FieldOfView)/3
wait()
end
Cam.FieldOfView = zoomMin
end
function commandKeys(key)
if key == "z" and canZoom then
if not isZoomed then
zoomIn()
elseif isZoomed then
zoomOut()
end
end
end

4 comments
Probably a sign (arithmetic) error in your for loops.
To me, your not calling 'commandKeys' anywhere in the code, so, it's not going to run. :P Ya Silly Billy. :P
So just commandkey(key) at the end, right?
I assumed you called the function at the end of the script and just didn't include it. Check my answer.