The actual gun itself is from Lego Star Wars III the video game. I looked closely at what pieces made the gun and then made some for my own guys.
About this creation
An overhead view. This really looks nice because you can see that both arms are holding on to the gun! I did this without any modification to the gun. I just had the camera look at the minifigure a certain way to make it look like the arm is attached in the correct position.
Here is the actual gun, with all of the correct pieces and colors from the game.
Here is the same pose but from the other side so you can see how I attached the arm to the gun.
If you want to have both arms attached to the minifigure, you end up with this.
So I added a joy-stick piece to the gun and angled it a certain way so that it'll fit right in the minifigure's hand....
This is with the modification to the gun.
When I first build the gun, I used the joy-stick piece. Then I figured out if I took the left arm out and angled it a certain way, I could make the clone trooper look like his arm bends inward! So I experimented and figured out a way. When I don't need that look, I just add on the joy-stick.