local function i(i,k)if k then return end if i.UserInputType==Enum.UserInputType.Keyboard and(i.KeyCode==Enum.KeyCode.LeftShift or i.KeyCode==Enum.KeyCode.RightShift)then mouseLockSwitchFunc()end end local function k()IsShiftLockMode=isShiftLockMode()if IsShiftLockMode then if ShiftLockIcon then ShiftLockIcon.Visible=true end if IsShiftLocked then Mouse.Icon=SHIFT_LOCK_CURSOR ShiftLockController.OnShiftLockToggled:Fire()end if not IsActionBound then InputCn=UserInputService.InputBegan:connect(i)IsActionBound=true end end end GameSettings.Changed:connect(function(i)if i=="\067\111\110\116\114\111\108\077\111\100\101"then if GameSettings.ControlMode==Enum.ControlMode.MouseLockSwitch then k()else disableShiftLock()end elseif i=="\067\111\109\112\117\116\101\114\077\111\118\101\109\101\110\116\077\111\100\101"then if GameSettings.ComputerMovementMode==Enum.ComputerMovementMode.ClickToMove then disableShiftLock()else k()end end end)LocalPlayer.Changed:connect(function(i)if i=="\068\101\118\069\110\097\098\108\101\077\111\117\115\101\076\111\099\107"then if LocalPlayer.DevEnableMouseLock then k()else disableShiftLock()end elseif i=="\068\101\118\067\111\109\112\117\116\101\114\077\111\118\101\109\101\110\116\077\111\100\101"then if LocalPlayer.DevComputerMovementMode==Enum.DevComputerMovementMode.ClickToMove or LocalPlayer.DevComputerMovementMode==Enum.DevComputerMovementMode.Scriptable then disableShiftLock()else k()end end end)LocalPlayer.CharacterAdded:connect(function(i)if not UserInputService.TouchEnabled then initialize()end end)

local function onShiftInputBegan(inputObject, isProcessed)
	if isProcessed then return end
	if inputObject.UserInputType == Enum.UserInputType.Keyboard and
		(inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.RightShift) then
		--
		mouseLockSwitchFunc()
	end
end

local function enableShiftLock()
	IsShiftLockMode = isShiftLockMode()
	if IsShiftLockMode then
		if ShiftLockIcon then
			ShiftLockIcon.Visible = true
		end
		if IsShiftLocked then
			Mouse.Icon = SHIFT_LOCK_CURSOR
			ShiftLockController.OnShiftLockToggled:Fire()
		end
		if not IsActionBound then
			InputCn = UserInputService.InputBegan:connect(onShiftInputBegan)
			IsActionBound = true
		end
	end
end

GameSettings.Changed:connect(function(property)
	if property == 'ControlMode' then
		if GameSettings.ControlMode == Enum.ControlMode.MouseLockSwitch then
			enableShiftLock()
		else
			disableShiftLock()
		end
	elseif property == 'ComputerMovementMode' then
		if GameSettings.ComputerMovementMode == Enum.ComputerMovementMode.ClickToMove then
			disableShiftLock()
		else
			enableShiftLock()
		end
	end
end)

LocalPlayer.Changed:connect(function(property)
	if property == 'DevEnableMouseLock' then
		if LocalPlayer.DevEnableMouseLock then
			enableShiftLock()
		else
			disableShiftLock()
		end
	elseif property == 'DevComputerMovementMode' then
		if LocalPlayer.DevComputerMovementMode == Enum.DevComputerMovementMode.ClickToMove or
			LocalPlayer.DevComputerMovementMode == Enum.DevComputerMovementMode.Scriptable then
			--
			disableShiftLock()
		else
			enableShiftLock()
		end
	end
end)

LocalPlayer.CharacterAdded:connect(function(character)
	-- we need to recreate guis on character load
	if not UserInputService.TouchEnabled then
		initialize()
	end
end)
