Airsoft solenoid controller

I don't have a PC to run the IDE so can only comment on your code.

Once you have detected the button is pressed and flag is false, you need to change the flag to true. Put this just before you activate the output. Then use the flag in another check to test if the trigger is released.

if ( (buttonState == LOW) && (buttonPressed == true) ).
//button has been released and output has been activated
buttonPressed = false
// reset flag. this will then allow the output to be triggered next time

Get it working using "delay" then convert to using "millis".

Your code uses the button to apply 5v to the input pin. The preferred way is to apply a gnd. Switching 5v risks shorting the supply. You also need to tie the input to either supply (depending on which polarity you switch). Preferred to use a R (10k) to 5v, to tie input to 5v then look for a change to gnd. You can also use an internal R connected via software.

Weedpharma