local U=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local L=U.TouchEnabled if L then local U=game.Players.LocalPlayer:WaitForChild("\080\108\097\121\101\114\071\117\105")local L=game.Players.LocalPlayer:WaitForChild("\080\108\097\121\101\114\083\099\114\105\112\116\115")local H="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\109\111\117\115\101\076\111\099\107\095\111\102\102\046\112\110\103"local q="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\109\111\117\115\101\076\111\099\107\095\111\110\046\112\110\103"local u="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\077\111\117\115\101\076\111\099\107\101\100\067\117\114\115\111\114\046\112\110\103"local h=(L:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")).CameraModule local Q=(require(h)).new()local z=require(h.MouseLockController)Q.activeMouseLockController=z.new()local e=Q.activeMouseLockController:GetBindableToggleEvent()if e then e:Connect(function()Q:OnMouseLockToggled()end)end local t=Q.activeMouseLockController local K=Instance.new("\070\114\097\109\101")K.Name="\066\111\116\116\111\109\076\101\102\116\067\111\110\116\114\111\108"K.Size=UDim2.new(.1,0,.1,0)K.Position=UDim2.new(1,0,1,0)K.AnchorPoint=Vector2.new(1,1)K.BackgroundTransparency=1 K.ZIndex=10 K.Parent=script.Parent local M=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")M.Name="\077\111\117\115\101\076\111\099\107\076\097\098\101\108"M.Size=UDim2.new(1,0,1,0)M.Position=UDim2.new(0,0,0,0)M.BackgroundTransparency=1 M.Image=H M.Visible=true M.Parent=K local R=Instance.new("\070\114\097\109\101")R.Name="\077\105\100\100\108\101\073\099\111\110"R.Size=UDim2.new(.1,0,.1,0)R.Position=UDim2.new(.5,0,.5,0)R.AnchorPoint=Vector2.new(.5,.5)R.BackgroundTransparency=1 R.ZIndex=10 R.Visible=false R.Parent=script.Parent local v=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")v.Name="\077\111\117\115\101\076\111\099\107\076\097\098\101\108"v.Size=UDim2.new(1,0,1,0)v.Position=UDim2.new(0,0,0,0)v.BackgroundTransparency=1 v.Image=u v.Visible=true v.Parent=R local k=Instance.new("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116")k.AspectRatio=1 k.DominantAxis="\072\101\105\103\104\116"k.Parent=K;(k:Clone()).Parent=R e:Connect(function()local U=Q.activeMouseLockController:IsMouseLocked()M.Image=U and q or H if SHOW_CENTER_CURSOR then R.Visible=U end end)M.Activated:connect(function()t:DoMouseLockSwitch(0,Enum.UserInputState.Begin)end)end
------------------------------------------------------------------------
--Actual script starts here. I don't reccomend modifying anything past this point.

local UserInputService = game:GetService("UserInputService")

local IsMobile = UserInputService.TouchEnabled --Is true if on mobile.

if IsMobile then --Only does things if it's on mobile.
	local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	local PlayerScripts = game.Players.LocalPlayer:WaitForChild("PlayerScripts")

	local SHIFT_LOCK_OFF = "rbxasset://textures/ui/mouseLock_off.png"
	local SHIFT_LOCK_ON = "rbxasset://textures/ui/mouseLock_on.png"
	local SHIFT_LOCK_CURSOR = "rbxasset://textures/MouseLockedCursor.png"

	--This essentially does what the scripts do for non-mobile players.
	--It is important to do it or else shift lock wouldn't work on mobile.
	local CM = PlayerScripts:WaitForChild("PlayerModule").CameraModule
	local CameraModule = require(CM).new()
	local MLC = require(CM.MouseLockController)

	CameraModule.activeMouseLockController = MLC.new()
	local toggleEvent = CameraModule.activeMouseLockController:GetBindableToggleEvent()
	if toggleEvent then
		toggleEvent:Connect(function()
			CameraModule:OnMouseLockToggled()
		end)
	end

	--Create the gui.
	local MouseLockController = CameraModule.activeMouseLockController
	local frame = Instance.new("Frame")
	frame.Name = "BottomLeftControl"
	frame.Size = UDim2.new(0.1, 0, 0.1, 0)
	frame.Position = UDim2.new(1, 0, 1, 0)
	frame.AnchorPoint = Vector2.new(1, 1)
	frame.BackgroundTransparency = 1
	frame.ZIndex = 10
	frame.Parent = script.Parent

	local ShiftLockIcon = Instance.new("ImageButton")
	ShiftLockIcon.Name = "MouseLockLabel"
	ShiftLockIcon.Size = UDim2.new(1, 0, 1, 0)
	ShiftLockIcon.Position = UDim2.new(0, 0, 0, 0)
	ShiftLockIcon.BackgroundTransparency = 1
	ShiftLockIcon.Image = SHIFT_LOCK_OFF
	ShiftLockIcon.Visible = true
	ShiftLockIcon.Parent = frame

	local frame2 = Instance.new("Frame")
	frame2.Name = "MiddleIcon"
	frame2.Size = UDim2.new(0.1, 0, 0.1, 0)
	frame2.Position = UDim2.new(0.5, 0, 0.5, 0)
	frame2.AnchorPoint = Vector2.new(0.5, 0.5)
	frame2.BackgroundTransparency = 1
	frame2.ZIndex = 10
	frame2.Visible = false
	frame2.Parent = script.Parent

	local MouseLockCursor = Instance.new("ImageButton")
	MouseLockCursor.Name = "MouseLockLabel"
	MouseLockCursor.Size = UDim2.new(1, 0, 1, 0)
	MouseLockCursor.Position = UDim2.new(0, 0, 0, 0)
	MouseLockCursor.BackgroundTransparency = 1
	MouseLockCursor.Image = SHIFT_LOCK_CURSOR
	MouseLockCursor.Visible = true
	MouseLockCursor.Parent = frame2

	local arc = Instance.new("UIAspectRatioConstraint")
	arc.AspectRatio = 1
	arc.DominantAxis = "Height"
	arc.Parent = frame
	arc:Clone().Parent = frame2

	--This event fires when shift lock is activated.
	--It just changes the icon.
	toggleEvent:Connect(function()
		local IsLocked = CameraModule.activeMouseLockController:IsMouseLocked()
		ShiftLockIcon.Image = IsLocked and SHIFT_LOCK_ON or SHIFT_LOCK_OFF
		if SHOW_CENTER_CURSOR then
			frame2.Visible = IsLocked
		end
	end)

	--When the icon is pressed, get the camera module to toggle shift lock.
	ShiftLockIcon.Activated:connect(function()
		MouseLockController:DoMouseLockSwitch(0, Enum.UserInputState.Begin)
	end)
end
