Can't get aiming zoom to work

So I’m trying to make a super simple gun system, and I’ve got everything else working so far; but making the camera zoom in when you hold right click and then zoom back out afterwards has taken me hours and it still won’t work. I’m new to scripting, don’t do it that often, and I’m not very good at it. I just wanted to know for what reason my script isn’t working.

Cam = game.Workspace.CurrentCamera
Tool = script.Parent 
Player = game.Players.LocalPlayer
Players = game:GetService("Players")
player = Players.LocalPlayer
mouse = player:GetMouse()

Tool.Unequipped:connect(function()
Cam.FieldOfView = 70
Player.CameraMode = "Classic"
end)

zoomed = false
function ZOOM(mouse)
if mouse.Button2Down and not zoomed then
zoomed = true
Cam.FieldOfView = 50
Player.CameraMode = "Classic"
elseif mouse.Button2Up and zoomed then
zoomed = false
Cam.FieldOfView = 70
Player.CameraMode = "Classic"
end
end
Tool.Equipped:connect(function(mouse)
mouse.ButtonDown:connect(ZOOM)
end)

add this at the end

change to

mouse.Button2Down:connect(ZOOM)

and at the end add

mouse.Button2Up:connect(ZOOM)
1 Like

If I were you I would change :connect to :Connect, :connect is deprecated.

1 Like