Player.CharacterAdded:Connect(OnCharacterAdded)if Player.Character then OnCharacterAdded(Player.Character)end do UserInputService.InputBegan:Connect(OnInputBegan)UserInputService.TextBoxFocused:Connect(function()TextBoxFocused=true end)UserInputService.TextBoxFocusReleased:Connect(function()TextBoxFocused=false end)HotkeyFns[DROP_HOTKEY_VALUE]=function()UnequipAllTools()end UserInputService.Changed:Connect(OnUISChanged)OnUISChanged("\075\101\121\098\111\097\114\100\069\110\097\098\108\101\100")if UserInputService:GetGamepadConnected(Enum.UserInputType.Gamepad1)then gamepadConnected()end UserInputService.GamepadConnected:Connect(function(A)if A==Enum.UserInputType.Gamepad1 then gamepadConnected()end end)UserInputService.GamepadDisconnected:Connect(function(A)if A==Enum.UserInputType.Gamepad1 then gamepadDisconnected()end end)end function BackpackScript.SetBackpackEnabled(S,A)BackpackEnabled=A end function BackpackScript.IsOpened(A)return BackpackScript.IsOpen end function BackpackScript.GetBackpackEnabled(A)return BackpackEnabled end function BackpackScript.GetStateChangedEvent(A)return Backpack.StateChanged end RunService.Heartbeat:Connect(function()OnIconChanged(BackpackEnabled)end)return BackpackScript

Player.CharacterAdded:Connect(OnCharacterAdded)
if Player.Character then
	OnCharacterAdded(Player.Character)
end

do -- Hotkey stuff
	
	-- Listen to key down
	UserInputService.InputBegan:Connect(OnInputBegan)

	-- Listen to ANY TextBox gaining or losing focus, for disabling all hotkeys
	UserInputService.TextBoxFocused:Connect(function() TextBoxFocused = true end)
	UserInputService.TextBoxFocusReleased:Connect(function() TextBoxFocused = false end)

	-- Manual unequip for HopperBins on drop button pressed
	HotkeyFns[DROP_HOTKEY_VALUE] = function() --NOTE: HopperBin
		UnequipAllTools()
	end

	-- Listen to keyboard status, for showing/hiding hotkey labels
	UserInputService.Changed:Connect(OnUISChanged)
	OnUISChanged('KeyboardEnabled')

	-- Listen to gamepad status, for allowing gamepad style selection/equip
	if UserInputService:GetGamepadConnected(Enum.UserInputType.Gamepad1) then
		gamepadConnected()
	end
	UserInputService.GamepadConnected:Connect(function(gamepadEnum)
		if gamepadEnum == Enum.UserInputType.Gamepad1 then
			gamepadConnected()
		end
	end)
	UserInputService.GamepadDisconnected:Connect(function(gamepadEnum)
		if gamepadEnum == Enum.UserInputType.Gamepad1 then
			gamepadDisconnected()
		end
	end)
end

function BackpackScript:SetBackpackEnabled(Enabled)
	BackpackEnabled = Enabled
end

function BackpackScript:IsOpened()
	return BackpackScript.IsOpen
end

function BackpackScript:GetBackpackEnabled()
	return BackpackEnabled
end

function BackpackScript:GetStateChangedEvent()
	return Backpack.StateChanged
end

RunService.Heartbeat:Connect(function()
	OnIconChanged(BackpackEnabled)
end)

return BackpackScript
