local M=0 IconController.iconAdded:Connect(function(B)topbarIcons[B]=true if IconController.gameTheme then B:setTheme(IconController.gameTheme)end B.updated:Connect(function()IconController.updateTopbar()end)B.selected:Connect(function()local M=IconController.getIcons()for M,S in pairs(M)do if B.deselectWhenOtherIconSelected and(S~=B and(S.deselectWhenOtherIconSelected and S:getToggleState()=="\115\101\108\101\099\116\101\100"))then S:deselect(B)end end end)M=M+1 B:setOrder(M)if IconController.controllerModeEnabled then IconController._enableControllerModeForIcon(B,true)end IconController:_updateSelectionGroup()IconController.updateTopbar()end)IconController.iconRemoved:Connect(function(M)topbarIcons[M]=nil M:setEnabled(false)M:deselect()M.updated:Fire()IconController:_updateSelectionGroup()end);(workspace:GetPropertyChangedSignal("\067\117\114\114\101\110\116\067\097\109\101\114\097")):Connect(bindCamera)

local iconCreationCount = 0
IconController.iconAdded:Connect(function(icon)
	topbarIcons[icon] = true
	if IconController.gameTheme then
		icon:setTheme(IconController.gameTheme)
	end
	icon.updated:Connect(function()
		IconController.updateTopbar()
	end)
	-- When this icon is selected, deselect other icons if necessary
	icon.selected:Connect(function()
		local allIcons = IconController.getIcons()
		for _, otherIcon in pairs(allIcons) do
			if icon.deselectWhenOtherIconSelected and otherIcon ~= icon and otherIcon.deselectWhenOtherIconSelected and otherIcon:getToggleState() == "selected" then
				otherIcon:deselect(icon)
			end
		end
	end)
	-- Order by creation if no order specified
	iconCreationCount = iconCreationCount + 1
	icon:setOrder(iconCreationCount)
	-- Apply controller view if enabled
	if IconController.controllerModeEnabled then
		IconController._enableControllerModeForIcon(icon, true)
	end
	IconController:_updateSelectionGroup()
	IconController.updateTopbar()
end)

IconController.iconRemoved:Connect(function(icon)
	topbarIcons[icon] = nil
	icon:setEnabled(false)
	icon:deselect()
	icon.updated:Fire()
	IconController:_updateSelectionGroup()
end)

workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(bindCamera)

