local function t(t,e)if PreventShiftLock==false or e==false then IsShiftLocked=t~=nil and t or not IsShiftLocked if e~=nil then PreventShiftLock=e if e==false and t==false then IsShiftLocked=ShiftLockedBefore end else ShiftLockedBefore=IsShiftLocked end if IsShiftLocked then ShiftLockIcon.Image=SHIFT_LOCK_ON Mouse.Icon=SHIFT_LOCK_CURSOR else ShiftLockIcon.Image=SHIFT_LOCK_OFF Mouse.Icon=""end ShiftLockController.OnShiftLockToggled:Fire()end end local function e()if ScreenGui then ScreenGui:Destroy()ScreenGui=nil end ScreenGui=Instance.new("\083\099\114\101\101\110\071\117\105")ScreenGui.Name="\067\111\110\116\114\111\108\071\117\105"local e=Instance.new("\070\114\097\109\101")e.Name="\066\111\116\116\111\109\076\101\102\116\067\111\110\116\114\111\108"e.Size=UDim2.new(0,130,0,46)e.Position=UDim2.new(0,0,1,-46)e.BackgroundTransparency=1 e.Parent=ScreenGui ShiftLockIcon=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")ShiftLockIcon.Name="\077\111\117\115\101\076\111\099\107\076\097\098\101\108"ShiftLockIcon.Size=UDim2.new(0,31,0,31)ShiftLockIcon.Position=UDim2.new(0,12,0,2)ShiftLockIcon.BackgroundTransparency=1 ShiftLockIcon.Image=IsShiftLocked and SHIFT_LOCK_ON or SHIFT_LOCK_OFF ShiftLockIcon.Visible=true ShiftLockIcon.Parent=e ShiftLockIcon.MouseButton1Click:connect(t)ScreenGui.Parent=IsShiftLockMode and PlayerGui or nil end
--[[ Local Functions ]]
--
local function onShiftLockToggled(Value, Lock) -- NEW: everything here
	-- Process if not prevented, or prevention being disabled
	if PreventShiftLock == false or Lock == false then
		-- Change
		IsShiftLocked = Value ~= nil and Value or not IsShiftLocked

		-- Begin prevention
		if Lock ~= nil then
			PreventShiftLock = Lock
			if Lock == false and Value == false then -- When unlocked set to prior state before lock
				IsShiftLocked = ShiftLockedBefore
			end
		else
			ShiftLockedBefore = IsShiftLocked -- Remember for when unlocking
		end

		-- Update mouse cursor
		if IsShiftLocked then
			ShiftLockIcon.Image = SHIFT_LOCK_ON
			Mouse.Icon = SHIFT_LOCK_CURSOR
		else
			ShiftLockIcon.Image = SHIFT_LOCK_OFF
			Mouse.Icon = ""
		end

		-- Fire!
		ShiftLockController.OnShiftLockToggled:Fire()
	end
end

local function initialize()
	if ScreenGui then
		ScreenGui:Destroy()
		ScreenGui = nil
	end
	ScreenGui = Instance.new("ScreenGui")
	ScreenGui.Name = "ControlGui"

	local frame = Instance.new("Frame")
	frame.Name = "BottomLeftControl"
	frame.Size = UDim2.new(0, 130, 0, 46)
	frame.Position = UDim2.new(0, 0, 1, -46)
	frame.BackgroundTransparency = 1
	frame.Parent = ScreenGui

	ShiftLockIcon = Instance.new("ImageButton")
	ShiftLockIcon.Name = "MouseLockLabel"
	ShiftLockIcon.Size = UDim2.new(0, 31, 0, 31)
	ShiftLockIcon.Position = UDim2.new(0, 12, 0, 2)
	ShiftLockIcon.BackgroundTransparency = 1
	ShiftLockIcon.Image = IsShiftLocked and SHIFT_LOCK_ON or SHIFT_LOCK_OFF
	ShiftLockIcon.Visible = true
	ShiftLockIcon.Parent = frame

	ShiftLockIcon.MouseButton1Click:connect(onShiftLockToggled)

	ScreenGui.Parent = IsShiftLockMode and PlayerGui or nil
end
