Hello! A couple weeks back I made a gun when you hold down right click it plays an animation that you "Zoom in", but I want to change the field of view also when I hold down right click on the script. It does work, but when I release right click it doesn't go back to the normal field of view. It just zooms in whenever I press down right click. It is inside of the handle of the gun. I added little notes to show you where in the script is the change of field of view. Any help would be appreciated! Here is the Local Script:
local mouse = game.Players.LocalPlayer:GetMouse() local Camera = game.Workspace.Camera tool = script.Parent.Parent mouse.Button2Down:Connect(function() tool.Equipped:connect(function() game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson Camera.FieldOfView = Camera.FieldOfView - 1.6 --Here is the problem local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.ZoomInAnimation) animation:Play() end) end) mouse.Button2Up:Connect(function() tool.Equipped:connect(function() game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson Camera.FieldOfView = Camera.FieldOfView - 1.6 --Here is the problem local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.ZoomOutAnimation) Animation:Play() end) end) tool.Unequipped:Connect(function(mouse) game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic Camera.FieldOfView = Camera.FieldOfView + 1.6 -- Here is the problem local player = game.Players.LocalPlayer local ActivTracks = player.Character.Humanoid:GetPlayingAnimationTracks() for _, v in pairs(ActivTracks) do v:Stop() end end)
Try changing "game.Workspace.Camera" to workspace.CurrentCamera
It's because this code:
14 - game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
You need to change the CameraMode to "Classic" here since this is part of the function that runs only when MouseButton2 is released.
14 - game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
Here is it revised. Should work.