Shift-Lock like camera but Acts weird on Right Click

Hello, I have a problem :

This happens when Spammed Right Click
or
Happens randomly while Trying to “Aim”
or
Sometiems Happens when you stop Holding for “Aim”

Here is script :

Script
-----------<| SERVICES |>-----------
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local UserGameSettings = UserSettings():GetService("UserGameSettings")
local ContextActionService = game:GetService("ContextActionService")
local TweenService = game:GetService("TweenService")
-----------<| SERVICES |>-----------

-----------<| PLAYER |>-----------
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Mouse = LocalPlayer:GetMouse()
local Camera = Workspace.CurrentCamera
-----------<| PLAYER |>-----------

-----------<| FOLDERS |>-----------
local EVENTS = ReplicatedStorage:WaitForChild("EVENTS")
-----------<| FOLDERS |>-----------

-----------<| MODULES |>-----------
local PlayerModule = script.Parent:WaitForChild("PlayerModule")
local CameraModule = PlayerModule:WaitForChild("CameraModule")
local CameraUtils = require(CameraModule:WaitForChild("CameraUtils"))
-----------<| MODULES |>-----------

-----------<| REMOTES |>-----------
local Fire_Tool = EVENTS:WaitForChild("Fire_Tool")
local Reload_Tool = EVENTS:WaitForChild("Reload_Tool")
-----------<| REMOTES |>-----------

-----------<| LOCAL_SETTINGS |>-----------
local HasTool = script.HasTool
local Clicked = false
local isAiming = script.isAiming
local RightClickActive = false

local TweenInfo_CameraOffset = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tweenInfo1 = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local tweenInfo2 = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)

local Mouse_xAngle = 0
local Mouse_yAngle = 0

local lastCameraMode
local MouseOffsetVertical = script.MouseOffsetVertical
local MouseLockOffsetValue = script.MouseLockOffsetValue
-----------<| LOCAL_SETTINGS |>-----------

--[[
---------------------------------------------------------------------
                        FUNCTIONS
---------------------------------------------------------------------
--]]

function Check_ForTools()
	-- Wait for Character to load properly
	Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()

	-- Check if the character has any tools
	if Character:FindFirstChild("GUN") or Character:FindFirstChild("TOOL") or Character:FindFirstChild("CONSUMABLE") then
		HasTool.Value = true
		MouseOffsetVertical.Value = 8
		MouseLockOffsetValue.Value = 23
	else
		HasTool.Value = false
		MouseOffsetVertical.Value = 0
		MouseLockOffsetValue.Value = 0
	end
end

function Change_Mouse_Icon()
	Mouse.TargetFilter = Character

	if HasTool.Value then
		UserInputService.MouseIcon = "rbxassetid://6976265170"
	else
		UserInputService.MouseIcon = "rbxassetid://6933336998"
	end
end

function Update_Mouse_Lock_Offset(offsetX, offsetY, useQuickTween)
	local tweenInfo = useQuickTween and tweenInfo2 or tweenInfo1
	local offsetX_Tween = TweenService:Create(MouseOffsetVertical, tweenInfo, { Value = offsetY })
	local offsetY_Tween = TweenService:Create(MouseLockOffsetValue, tweenInfo, { Value = offsetX })
	offsetX_Tween:Play()
	offsetY_Tween:Play()
end

function Mouse_Range_Limit(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		Mouse_xAngle = Mouse_xAngle - input.Delta.x * 0.4
		-- Clamp the vertical axis so it doesn't go upside down or glitch.
		Mouse_yAngle = math.clamp(Mouse_yAngle - input.Delta.y * 0.4, -80, 80)
	end
end

function Change_User_Settings(newMode)
	if lastCameraMode ~= newMode then
		if newMode == "Default" then
			UserInputService.MouseBehavior = Enum.MouseBehavior.Default
			UserGameSettings.RotationType = Enum.RotationType.MovementRelative
			Update_Mouse_Lock_Offset(0, 0)
		elseif newMode == "MouseRotate" then
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
			UserGameSettings.RotationType = Enum.RotationType.MovementRelative
			Update_Mouse_Lock_Offset(23, 8)
		elseif newMode == "MouseLock" then
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
			UserGameSettings.RotationType = Enum.RotationType.CameraRelative
			Update_Mouse_Lock_Offset(27, 8)
		end
		lastCameraMode = newMode
	end
end

function Check_RotateCameraWithMouse()
	if HasTool.Value and isAiming.Value then
		Change_User_Settings("MouseLock")
	elseif HasTool.Value then
		Change_User_Settings("MouseRotate")
	else
		Change_User_Settings("Default")
	end
end

function Adjust_Camera_Position()
	local objects = {
		Character,
	}
	for _, player in ipairs(Players:GetChildren()) do
		if player.Character then
			table.insert(objects, player.Character)
		end
	end
	local cutoffDistance = Camera:GetLargestCutoffDistance(objects)
	if cutoffDistance > 0 then
		Camera.CFrame = Camera.CFrame + Camera.CFrame.lookVector * cutoffDistance
		return true
	end
	return false
end

function Update_Camera()
	if Camera.CameraType == Enum.CameraType.Custom then
		Check_RotateCameraWithMouse()
		Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, 0)
		local horizontalOffset = (Camera.CFrame.lookVector * Vector3.new(1, 0, 1)):Cross(Vector3.new(0, 1, 0)).unit * MouseLockOffsetValue.Value / 10
		local verticalOffset = Vector3.new(0, MouseOffsetVertical.Value / 10, 0)
		local offset = horizontalOffset + verticalOffset
		Camera.CFrame = Camera.CFrame + offset
		Adjust_Camera_Position()
		Camera.Focus = Camera.Focus + offset
	end
end

function Reset_Camera()
	-- Optional: Reset camera if needed
end

--[[
---------------------------------------------------------------------
                        MAIN_FUNCTION
---------------------------------------------------------------------
--]]

-- Connect changes
HasTool.Changed:Connect(function()
	Change_Mouse_Icon()
	Check_RotateCameraWithMouse()
end)

isAiming.Changed:Connect(function()
	Change_Mouse_Icon()
	Check_RotateCameraWithMouse()
end)

-- Update functions
RunService.Stepped:Connect(function(deltaTime)
	Check_ForTools()
end)

Mouse.Button1Down:Connect(function()
	if not Clicked then
		Clicked = true
		-- PUT EVENT HERE
		task.wait(0.05) -- to not throttle RemoteEvents
		Clicked = false
	elseif Clicked then
		warn(LocalPlayer.Name.." Please Stop Throttling Remote Event")
	end
end)

Mouse.Button2Down:Connect(function()
	if not RightClickActive then
		RightClickActive = true
		isAiming.Value = true
	end
end)

Mouse.Button2Up:Connect(function()
	if RightClickActive then
		RightClickActive = false
		isAiming.Value = false
	end
end)

UserInputService.InputChanged:Connect(function(input)
	Mouse_Range_Limit(input)
end)

-- Bind to RenderStep for camera updates
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value + 1, Update_Camera)
RunService:BindToRenderStep("CameraReset", Enum.RenderPriority.Camera.Value - 1, Reset_Camera)


Seem to have found issue but not really…
Mouse appears in near marked position for no reason, there is nothing there to affect it’s position, i am sure of it

I am sure I locked mouse like Shift-lock so it shouldn’t happen i believe


Seem to have found issue but not really…
Mouse appears in near marked position for no reason, there is nothing there to affect it’s position, i am sure of it