dont expect any "answere"s at all if you're going to be so vague.
you need to supply some information on what you have SO FAR. an mfa would be the most helpful.
I mean like if i got a pistol, a uzi and a shotgun then i will press 1 for the pistol, 2 for the uzi and 3 for the shotgun and when the weapon changes the attack when you press the fire button should also change and thats my problem i don't know how to change the attack on fire button.
the easiest way is to have a counter. when its value is like 1 make it the pistol. value 2 make it a shotgun. etc etc. how you implement it into your game is really up to you.
theres waaaaaay to many ways to accomplish whatever it is youre trying to do cause youre being so vague.
simply put. you need to describe, IN DETAIL, what you ALREADY have, and what you WANT to accomplish.
first of all we dont even know what GENRE/VIEW the game is. side scrolling? top down? isometric? rpg? shooter? etc etc etc! are the sprites super detailed that you would need completely re animated weapons? or pixeled enough were having a generic gun shape can be used for all weapons.
see how long my post is? yours should be at least twice that long if not longer with all the details! not a 1 or two sentences saying "i need this now! help fast!" cause when no one helps you have only yourself to blame.