Stop firing when weapon energy hit's 0

Hello am trying to setup a weapon energy system. Basically it’s just a regenerating ammo system. I’ve got it mostly working atm but I have one small bug. If your holding down the fire button it won’t stop firing when your out of energy.
I think the basic problem here if your holding down the button it stays on my fire gun function and doesn’t check to see if you can still fire. I’ve fixing this with while loops but that just ended with my game crashing so wondering if anyone and any other idea’s on how to fix this.

No, no, no, no, no! Delete all of this code! I don’t even want to know where your “while loops” are because this is already a nightmare we are going to build this from scratch very simply. All you need to do is make something similar to what I have below.

That helped a lot thank you