Im working on a game and trying to make a custom script to enable and disable Shift Lock using a different key im confused cause in the docs it said something about a previous way being depricated in the mean time ive got something working where it uses mouse lock but is it as good as shift lock and is there a way to use shift lock that wont have a chance of getting broken in the future due to things changing
#Shift Lock
1 messages · Page 1 of 1 (latest)
what key do you want it to be
local shiftLock = script.Parent:WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController")
Control:WaitForChild("BoundKeys").Value = "LeftControl"
this is my script
just replace "LeftControl"
with the keybind youw ant
i used this for a little but i was worried about it breaking if they ever change it should i be worried or is it a dumb fear this is what im using currently and it works perfectly fine i think the built in shift lock may just be better though or am i also wrong about that
-- Shift Lock to Left Alt
local function onInput(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftAlt and UserInputService.MouseBehavior == Enum.MouseBehavior.Default then
print("Shift Lock Enabled") -- For Debugging
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
elseif input.KeyCode == Enum.KeyCode.LeftAlt and UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
print("Shift Lock Disabled") -- For Debugging
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
end
end
UserInputService.InputBegan:Connect(onInput)```
nah just use the script i sent
prob easier
if you want it on left alt
its not that hard
did you look at what i sent?
local shiftLock = script.Parent:WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController")
Control:WaitForChild("BoundKeys").Value = "LeftAlt"
i mean, its probably fine, but what i used wont ever break
so
up to you tbf
both work
id use the built in one
personally
are you able to change the look of the built in one
** You are now Level 2! **
if you know
yeah
id like to make it custom if possible
if not ill stick to this one which should let me change the cursor icon when activated
you would probably have to keep the same script in that case
i dont believe you can change it
alright well appreciate the help
one more question
how can i disable the original shit lock
enable mouselockoption
you could just do it in ur script tbg
but this works
preciate it sm
local starterPlayer = game:GetService("StarterPlayer")
starterPlayer.EnableMouseLockOption = false
more hassle than its worth
but its an option
@midnight dove
** You are now Level 13! **
update
you actually can change the image
local Control = script.Parent:WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController")
Control:WaitForChild("BoundKeys").Value = "LeftControl"
Control:WaitForChild("CursorImage").Value = "rbxassetid://5801470647"
i appreciate i actually already fully custom made mine so its cool it probably wouldve been easier to use default but mine also allows me to check if its on or off and do custom things with it like also things like camera smoothing and ect ect
is there any chance i could take a look at that system
im interested in how you did it
sure it might be a little messy and its definitely a lot more complicated now because its being used with other keybinds in the same script like lock on and other stuff but here and feel free to use and expand upon it and optimise it
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
-- check to use for other scripts
local isShiftLockEnabled = false
RunService.RenderStepped:Connect(function()
local character = LocalPlayer.Character
if not character then return end
local hrp = character:FindFirstChild("HumanoidRootPart")
local head = character:FindFirstChild("Head")
local neck = head and head:FindFirstChild("Neck")
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
-- makes sure camera follows like original shift lock not just locking mouse to middle of screen
if isShiftLockEnabled and hrp then
local cam = workspace.CurrentCamera
local lookVector = Vector3.new(cam.CFrame.LookVector.X, 0, cam.CFrame.LookVector.Z).Unit
hrp.CFrame = CFrame.new(hrp.Position, hrp.Position + lookVector)
if humanoid then
-- makes body stop moving
humanoid.AutoRotate = false
end
end
end)
-- Keybind
local function onInput(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.LeftAlt then
isShiftLockEnabled = not isShiftLockEnabled
print("Shift Lock", isShiftLockEnabled and "Enabled" or "Disabled")
UserInputService.MouseBehavior = isShiftLockEnabled and Enum.MouseBehavior.LockCenter or Enum.MouseBehavior.Default
local character = LocalPlayer.Character
if character then
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.AutoRotate = not isShiftLockEnabled
end
end
end
end
UserInputService.InputBegan:Connect(onInput)
also if you have any advice let me know or even any questions im always open to learning
@pale valve
this is cool, doesnt go to side as shift lock does, but still cool. no icon aswell?
for me it goes side to side like shift lock and no icon yet gonna do ui design later ive just been getting keybinds down for now
i assume this isnt meant to happen
yeah offset
no i could definitely do it but and im debating on if i want to but i may not
fair enough