Shiftlock not working

Hey i have this script and so i want when a tool is equipped it will make a forced shiftlock but for some reason its not working anyne know how to fix it

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart
local tool = script.Parent

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

tool.Equipped:Connect(function()
    shiftLock(true)
end)

tool.Unequipped:Connect(function()
    shiftLock(false)
end)

1 Like

first of all, is it local script?
and why you dont use “local function”?

Main Problem ig:
"if active then" checks if active exist, if u need to check if it's true or false you have to write
if active == true then 
so yeah i think this is the main problem

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.