This is a script I made a while ago, and it basically decreases the player's field of view when they hold right click, making a zoom effect. I want to change it to a toggle zoom, like the press mousebutton2 and it zooms, then they press it again to unzoom. here is the script.
local Speed = 0.5
local Max = 75
local Min = 74
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local function start(instance,info,goal)
return TweenService:Create(instance,info,goal)
end
local Zoom = start(workspace.CurrentCamera,TweenInfo.new(Speed,Enum.EasingStyle.Cubic),{FieldOfView = Max})
local Unzoom = start(workspace.CurrentCamera,TweenInfo.new(Speed,Enum.EasingStyle.Cubic),{FieldOfView = Min})
UserInputService.InputBegan:Connect(function(Input,Event)
if (Input.UserInputType == Enum.UserInputType.MouseButton2) then
Unzoom:Play()
end
end)
UserInputService.InputEnded:Connect(function(Input,Event)
if (Input.UserInputType == Enum.UserInputType.MouseButton2) then
Zoom:Play()
end
end)
I don't know how to turn it into a toggle thing.
