just give the entity a value of 0 if hidden and 1 if not ie
box = createbox()
boxvisibility = 1
if keyhit(h) and boxvisibility = 1
hideentity box : boxvisibility = 0
endif
if keyhit(j)) and boxvisibility = 0
showentity box : boxvisibility = 1
endif
box = createbox()
boxvisibility = 1
if keyhit(h) and boxvisibility = 1
hideentity box : boxvisibility = 0
endif
if keyhit(j)) and boxvisibility = 0
showentity box : boxvisibility = 1
endif