Mouse click breaks trigger variable C#

im not to sure how to describe this accurately, but i have a trigger box collider around my player controller and a trigger sphere collider around an ammo crate which is supposed to re-supply your ammo when you hit ‘E’ near it. i was debugging the variable which basically says that the player is near the ammo box when i noticed that clicking either mouse button changes the variable to false for seemingly no reason, also the variable doesn’t change to false when i leave the trigger radius.

here’s the relevant code for the player controller:
void OnTriggerEnter(Collider other) {

		if(other.gameObject.tag == "AmmoCrate") {
			nearbox = true;
			nearbox = false;

not sure if there is any other code i need to paste, but feel free to ask if there is.
thanks in advance to any helpers, this is driving me nuts.

The way you set it up, it won’t change back to false. What you’re saying is “if the tag of the object my player is colliding with is “AmmoCrate”, then nearbox is true, otherwise it’s false” - What you need to do is to set it false when your player ‘exits’ the trigger area.
OnTriggerEnter sets the flag to true (after checking for the “AmmoCrate” name), and OnTriggerExit should set it to false.

About the mouse clicks, could it be that they’re alternative keys to “Use”? (E)