Need help cycling through weapons with a single button

So I have looked up how to cycle weapons and all I can find tuts on is how to cycle using 1,2,3 etc. I was wondering how you cycle using a single button. Like I start the game with a gun and a sword. I press Q to switch from my gun to the sword then Q again to switch back.

So first go into youre projects settings and add the input Q weapon switcher.
Then create a boolean variable . When you press Q do a branch from the event. Check the boolean value. Then draw that weapon based off the value eg sword is equal to true, gun is equal to false. Once weapon is drawn you need to set the bool variable again so it might be best to make it into a custon function

Eg you start with sword bool = true
You press q it switches to gun then changes bool to false
You press q it switches to sword then changes bool to true etc etc

If you want multiple weapons more than two then give each weapon a variable value eg int so sword is 1 , gun is 2, knife is 3

then use the switch on int node to cycle through

What enigmaa wrote, but just bit more details:

Create integer variable “current_weapon” set its default value to -1 (or weapon you want as default -1).
Use switch on integer. Set output links to as many weapons you have. (they go from 0 to n-1)
Then connect code that switches on selected weapon to each output link.
To last link add code that sets integer variable (current_weapon) back to -1.
Before that whole Switch node add 1 to “current_weapon” variable that holds which weapon you use.

That is all, connect it to some key event.

All because i wanted to add: “use enums” they help with readability.

So when you have above code it is time to implement enumerator.
Create new enum in content browser (i think it is in right click menu in blueprints).
Call that enum “enum_weapon”. Open it in content browser (double click on it).
Now add names of all your weapons there.
Replace “current_weapon” integer with similar variable but this time of "enum_weapon_ type.
Now you can easily see which weapon you use, read its name and display it in user interface etc.
Makes life easier.

Try this. Good luck

use multigate node, thats about the easiest way to toggle on and switch through a variable amount of items with one click.