Gun Shiftlock On Equip Help

So I wanna make this for my gun that when the players fires their first shot (by pressing mousebutton1) it immediately puts the player into shiftlock , ive tried looking for certain scripts , couldnt find them i found one of them but it dosent work properly
My game uses PlayerModule for an inventory system and shiftlock glitches with it

How would i go on making that when one shot is fired from the gun it puts the player into shiftlock without bugging out

(The bug i faced before was it was in shiftlock but i was not able to move the camera using my mouse)

Any help is appreciated
Thanks

Try this setup:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")

local function enableShiftLock()
    -- Enable shift lock mode
    player.DevEnableMouseLock = true
    UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

    -- Set the camera mode to support shift lock
    local camera = workspace.CurrentCamera
    camera.CameraType = Enum.CameraType.Custom -- or Scriptable if you want more control
end

-- Function to detect the first shot fired
local function onFirstShot()
    enableShiftLock()
end

-- Example for detecting first shot using a tool's `Activated` event
local tool = script.Parent -- Assuming the script is a child of the tool
tool.Activated:Connect(function()
    onFirstShot()
end)

Can’t do this without permission. Best you can hope for is a workaround that works for you.

This dosent seem to have an effect i can provude you the gun model i made and maybe you could try working on it

Heres the link to it
Put the Holster , PistolAcc , Pistol in replicated storage
And put the game mgr in serverscriptservice