I want to make it so the fov won't change when the tool is unequipped, the current script doesn't work, here is my script:
--The whole script doesn't work but if I remove this it works but still does it even if you unequip the tool: --if tool.Unequipped then --camera.FieldOfView = 70 local mouse = game.Players.LocalPlayer:GetMouse() local camera = game.Workspace.CurrentCamera local tool = script.Parent mouse.Button2Down:Connect(function() --When you rightclick the fov changes camera.FieldOfView = 40 if tool.Unequipped then --But if it is unequipped it won't change the fov so it stays at 70 (Doesn't work) camera.FieldOfView = 70 end end) mouse.Button2Up:Connect(function() --When you release the right click it will go back to 70 camera.FieldOfView = 70 end)
This script is being used for a gun I made
local mouse = game.Players.LocalPlayer:GetMouse() local camera = game.Workspace.CurrentCamera local tool = script.Parent local character = game.Players.LocalPlayer.Character mouse.Button2Down:Connect(function() if tool.Parent == character then -- check if player is equipping the tool camera.FieldOfView = 40 local con do con = tool.Unequipped:Connect(function() -- wait for tool to be unequipped only once camera.FieldOfView = 70 con:Disconnect() end) end end end) mouse.Button2Up:Connect(function() if tool.Parent == character then camera.FieldOfView = 70 end end)