So I have a weapons system, and I need a proper working shift-lock system and I’m not sure how to access the official shift lock module functions so I have to rely on a local script, it works but it’s pretty “wonky” compared to the default shift lock
Video:
Script:
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local hum
local root
--Toggle Function:
function shiftLock(active)
if active then
hum.CameraOffset = Vector3.new(1.75,0,0)
hum.AutoRotate = false
RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0)
end)
else
hum.CameraOffset = Vector3.new(0,0,0)
RunService:UnbindFromRenderStep("ShiftLock")
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
hum.AutoRotate = true
end
end
script.Parent.Equipped:Connect(function()
shiftLock(true)
end)
script.Parent.Unequipped:Connect(function()
shiftLock(false)
end)
plr.CharacterAdded:Connect(function(character)
hum = character:WaitForChild("Humanoid")
root = hum.RootPart
end)
if plr.Character then
hum = plr.Character:WaitForChild("Humanoid")
root = hum.RootPart
end