Im really new to scripting and trying to make an aiming/zoom function when you hold down right click. I want it to trigger whenever you hold down right click and i dont want it to activate on tool function or anything. Im trying to tween the camera but it glitches and snaps back and forth from fovs and im not really sure how to fix it heres the code
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
Mouse.Button2Down:Connect(function()
local tweenInfo1 = TweenInfo.new(
0.3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
false,
0
)
local tween1 = TweenService:Create(camera, tweenInfo1, { FieldOfView = 60 })
tween1:Play()
if Mouse.Button2Up == true then
tween1:Cancel()
end
end)
Mouse.Button2Up:Connect(function()
local tweenInfo2 = TweenInfo.new(
0.3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
false,
0
)
local tween2 = TweenService:Create(camera, tweenInfo2, { FieldOfView = 100 })
tween2:Play()
if Mouse.Button2Down == true then
tween2:Cancel()
end
end)
I know the code is a mess but i have been trying to figure this out for a while now
