How to enable/disable shiftlock during gameplay

Trying to figure out a way to disable/enable shift lock camera during specific instances in the game. For example, the shift lock should be removed when the character change to a custom rig; it could then be enabled again if you switch back to your original character. Is it possible to do this or would I have to make a custom camera script?

From what I could find, the only way to enable & disable it while in-game is by making you’re own shift-lock system

Yea, I guess that’s the only way. Thanks for the help.

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)
9 Likes

You may have to modify CameraModule to be able to access the camera, because there’s a flag to expose an empty API. If you change it to this around line 25 it should always work:

local FFlagUserRemoveTheCameraApi = false
--local FFlagUserRemoveTheCameraApi do
--	local success, result = pcall(function()
--		return UserSettings():IsUserFeatureEnabled("UserRemoveTheCameraApi")
--	end)
--	FFlagUserRemoveTheCameraApi = success and result
--end

If you do that, you should always be able to do this:

local InputS = game:GetService("UserInputService")
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local CameraModule = PlayerModule.cameras

InputS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F then
		local MouseLockController = CameraModule.activeMouseLockController
		MouseLockController:DoMouseLockSwitch(nil, Enum.UserInputState.Begin)
	end
end)
3 Likes