This question was asked by Leo and Sol from West Sussex, UK.
The first thing to think about is whether the gun would fire in space, where there’s no oxygen. If it was an old gun it wouldn’t work, but modern bullets have additional chemicals that allow them to fire even where there’s no oxygen.
The bullet wouldn’t fire in slow motion as some people think, it would fire at the same speed as here on Earth. What would be different is that there’s no air in space to create drag, so unless an object was in the way the bullet could travel onwards forever. So, unfortunately, would you. Newton’s third law states that for every action there is an equal and opposite reaction; what this means is that as the gun fired the bullet forwards, you would be pushed backwards by the same amount of force. Because your mass is far greater than the bullet’s you wouldn’t be travelling as fast, but you’d definitely be floating away.
Another possible problem could occur if you fired the gun while orbiting a planet. The bullet would orbit it as well until it caught up with you, and in theory you could end up shooting yourself in the back. Probably not a good idea.
But did you know that Soviet (and later Russian) cosmonauts used to take a gun into space with them? The TOZ-32 had 3 barrels – one to fire shotgun shells, one to fire rifle bullets and one to fire flares. It also had a folding stock that could double as a shovel, and a swing-out machete. It was included in the standard Soyuz survival kit, the idea being that if the Soyuz capsule landed back on Earth in hostile conditions the cosmonauts could defend themselves and hunt if they needed to. Although the gun hasn’t been included on trips into space since around 2007, it’s still on the official inventory for Russian rockets; before every launch a vote is taken to remove the gun from the kit for that particular flight.