How do you force shiftlock on without it being able to be turned off? Possibly with a script or option?
here’s a script to do so
--Local script in StarterPlayerCharacter
--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.AutoRotate = true --Let the humanoid handle the camera rotations again.
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
end
end
--Disable and Enable:
shiftLock(true) -- Toggle shift lock
print("Shift lock turned on!")
task.wait(7)
shiftLock(false) --Toggle off shift Lock
print("Shift lock turned off!")
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.