How to limit number of (working) box triggers in level?

how about a key system? basically they are only able to enter 5 rooms before their “keys” deplete. the keys dont even need to be something the player knows about if you dont want them to.