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)
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)