Shift lock camera not working

I found this code from here and it worked as like a toggle, but I’ve made edits so it’s just the default camera (I don’t want players to be able to toggle camera at all, camera should always stay in the shift locked state)

local Players = game:GetService('Players')

local Player = Players.LocalPlayer

local PlayerModule = Player.PlayerScripts:WaitForChild('PlayerModule')
local Cameras = require(PlayerModule):GetCameras()
local BoundKeys = PlayerModule.CameraModule.MouseLockController:WaitForChild('BoundKeys')
local OldBoundKeys = BoundKeys.Value

local function ToggleLock()
	print('Start')
	local CameraController = Cameras.activeCameraController
	local MouseLockController = Cameras.activeMouseLockController

	if MouseLockController:GetIsMouseLocked() then
		MouseLockController:OnMouseLockToggled()
	end
		
	CameraController:SetMouseLockOffset(Vector3.new())
	CameraController:SetIsMouseLocked(true)
	BoundKeys.Value = ''
	print('Done')
end

ToggleLock()

Placed in a LocalScript inside StarterPlayerScripts. All prints print

1 Like

It seems like you can set an arbitrary wait() at the top (not recommended) or place the script under StarterCharacterScripts to circumvent this issue. I think some part of the CameraModule is overriding it, but I was unable to pinpoint it after a brief scan.