i have a script which locks the cursor in the screen, and enables shiftlock.
however, i now cannot move the cursor around…
how could i fix this?
heres the script:
--Services:
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
--Variables:
local plr = game:GetService("Players").LocalPlayer
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart -- The HumanoidRootPart
--Toggle Function:
function shiftLock(active) --Toggle shift.lock function
if active then
hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
end)
else
hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
end
end
--Disable and Enable:
shiftLock(true) -- Toggle shift lock
--[[
shiftLock(false) --Toggle off shift Lock
]]