my gun isn’t stopping when equipped and 2 arms wont stay close together
https://gyazo.com/51586d9203f116003c8c4cb2b6a39bff
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Gun = script.Parent.Parent:FindFirstChild('Gun')
local UserInputService = game:GetService('UserInputService')
local TweenService = game:GetService('TweenService')
local Camera = workspace.CurrentCamera
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Index = {['ZoomIn'] = 60, ['ZoomOut'] = 70}
local Info = TweenInfo.new(0.21, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local function TweenCamera(Properties)
local T = TweenService:Create(game.Workspace.CurrentCamera, Info, Properties)
T:Play()
end
local equipped = false
local function Zoom(key)
if Player and Player.Character then
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType[key] then
if equipped then
local Properties = {FieldOfView = Index.ZoomIn}
TweenCamera(Properties)
Mouse.Icon = ''
local Animation = Instance.new('Animation')
Animation.AnimationId = 'rbxassetid://4842699362'
local AnimLoad = Player.Character.Humanoid:LoadAnimation(Animation)
AnimLoad:Play()
wait(0.5)
Animation:Destroy()
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType[key] then
if equipped then
local Properties = {FieldOfView = Index.ZoomOut}
TweenCamera(Properties)
wait(0.1)
Mouse.Icon = 'rbxassetid://61374156'
end
end
end)
end
end
Gun.Equipped:Connect(function()
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonX then
equipped = true
Zoom('MouseButton2')
Mouse.Icon = 'rbxassetid://61374156'
end
end)
end)
Gun.Unequipped:Connect(function()
local Properties = {FieldOfView = Index.ZoomOut}
TweenCamera(Properties)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonX then
local Propertiesg = {FieldOfView = Index.ZoomOut}
TweenCamera(Propertiesg)
equipped = false
wait(0.1)
Mouse.Icon = ''
end
end)
end)