How to prevent player from unselecting ui elements?

I want to make an inventory menu so that when a console player opens it, they’ll automatically select an element. This I have and it works perfectly, my issue is that after the player opens their inventory, they can just unselect the ui. The only time I don’t want the player selecting a ui element is when their inventory is closed. So is there a way to temporarily prevent console players from unselecting gui while their inventory is open? Or, the un-preferred route, detect if the player isn’t selecting a ui element at all? Thanks

Not sure what you mean by UI elements, so I’ll take two guesses…

  1. If you mean normal UI elements: you could set a transparent screen UI over the normal UI.
  2. If you ment the roblox UI elements, aka backpack: game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

I mean normal gui elements and placing gui elements over my buttons won’t prevent the player from unselecting the instance.