How to enable/disable shiftlock during gameplay

Update:
Found an alternative solution mentioned here but since Roblox removed the API you can find the old scripts from here.

Made an example of shiftlock toggle using the L key below:

local Client = DATA.Client
local Character = DATA.Character
	
local PlayerModule = game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")
local Cameras = require(PlayerModule):GetCameras()
local CameraController = Cameras.activeCameraController
local MouseLockController = Cameras.activeMouseLockController


DATA.UserInputService.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.L then
		if MouseLockController:GetIsMouseLocked() then
			MouseLockController:OnMouseLockToggled()
			CameraController:SetIsMouseLocked(false)
		else
			MouseLockController:OnMouseLockToggled()
			CameraController:SetIsMouseLocked(true)
		end
	end
end)
11 Likes