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