Toggle Shiftlock

Hello, so I have in the StarterPlayer the EnableMouseLockOption is disabled so I can use the shift key for sprint instead of shift lock, and I’m trying to make the shift lock key work using the left control key, but it won’t work.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local userInputService = game:GetService("UserInputService")

local shiftLockEnabled = false

local function toggleShiftLock()
	shiftLockEnabled = not shiftLockEnabled
	humanoid.AutoRotate = not shiftLockEnabled

	if shiftLockEnabled then
		userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	else
		userInputService.MouseBehavior = Enum.MouseBehavior.Default
	end
end

userInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed and input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.LeftControl then
		toggleShiftLock()
	end
end)

Any solutions?

2 Likes

Here is the solution you are looking for :slight_smile: It basically rebinds Shift Lock entirely!

3 Likes

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