So you just want it to hide only? If that's the case then...
function txtStart(text)
if text.Owner:getId().tableId == eCharacters or text.Owner == nil then
Interfaces["inventory"].Visible = false
end
end
registerEventHandler("textStarted", "txtStart")
I have no idea what your inventory looks like or how you've rigged it up. Anyway, you're going to have to use Lua to show & hide it as needed.
Use an execute a script action part & with this line of code whenever you want to show the interface... replace "inventory" with the actual name of the inventory interface.
Interfaces["inventory"].Visible = true
& same again when you want to hide it, but true should be false instead.