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)

1 comment
'mouse.Button2Down:Connect(function() 05 tool.Equipped:connect(function()' You have the equipped function within the right click function, which could be causing it.