I've experience with both guns (sport shooting), and swords (HEMA).
As others have noted, you're going to have to bend one or more of your restrictions slightly.
Lots of the answers suggest reasons that guns would be less preferable to carry (e.g. cost, or dangerous to use), but these wouldn't make a fight between a gun and a sword user more balanced, which I believe is what you're trying to achieve.
To do this, you'll have to balance the lethality of guns and swords.
Remember that swords work in two ways: in the thrust (stabbing with the tip), or cut (drawing through in a cutting motion with a sharp edge). They do not work but hitting people with the sharp edge, despite what films would have you believe. Try it with a carving knife on a pork joint, you'll not get through the skin.
Range
Reducing the range advantage would help, as at larger ranges, guns have >0 lethality, whereas swords have 0 lethality.
Two options are to reduce the range of encounters, or to slow the draw of a gun.
Don't underestimate how fast or far a swordsman can reach. The "21 foot rule" is a real thing from law enforcement – within 21ft, a suspect with a knife can draw their knife and kill an officer faster than an office can react to draw their weapon and shoot. And that's a 4" knife. You wouldn't believe how far and fast a lunge with a montante is. (A montante is a very large sword typically used by bodyguards, which was typically carried resting on the shoulder; it's usually used two-handed, but you can 'draw' from the shoulder and lunge single-handed like a rapier, though it's a bit of a gamble as recovery is very difficult.)
So if you've got a scenario where ranges are short (probably any residential space), lethality will tip towards a sword user. If you're wanting a balanced 50:50 sword/gun kill rate, a larger range will be fine even for a knife.
You can further decrease the speed of a gun vs a sword with the use of laws – e.g. a law that prevents open carry of a gun, but permits open carry of swords. If guns have to be secured with a combination lock on the trigger (and only legal to release the lock if you're in danger), a sword-user is probably more lethal in any indoor setting. That might not feel like a realistic law, but you can imagine it being proposed by the anti-gun lobby in the US.
Lethality
The other option is to make guns less lethal, so that it requires several shots to stop an attacker. One option would be to move to 'non-lethal' ammo (it'll have to be due to law, as it's not hard to form a bullet if metal is available). A black market in lead bullets might exist, which might work in your story?
Perhaps the law prevents general civilians from using metal ammo, but permits it for those who are better trained like mercs?
Game Mechanics
However, you're talking about a game. In real life, the first bullet hit wins a fight. But people don't realise that usually the first knife stab or even punch wins the fight. This doesn't usually make for a fun game mechanic if the first hit you take in the game kills you. Sword or gun fights where they slowly both carve bits off each other until one reaches 0-HP are much more fun, but not realistic.
So if you want a hard-science answer for a fun game, it's going to involve armour. It takes relatively little armour to stop a sword (sword fights in plate armour are largely about pinning the other guy down or knocking him over with a big blunt 'sword' (club), and then stabbing through the joints with a knife until he bleeds to death). However, most modern guns would penetrate this armour (unless you're lucky and get a deflection).
Note though that heavy armour is really heavy and would never be worn 'normally'. Leather with some light metal over the key areas is probably as heavy as anyone would want to wear as regular wear.
So your options are:
invent a light non-newtonian armour which provides much better protection against guns (high velocity impact) than swords (low velocity cutting). Stuff like this is in development; in our world it won't cause a move back to swords (because bigger calibre weapons and longer ranges are the norm, and we rely on law-enforcement rather than wearing armour to keep civilians safe), but in your world it could well provide what you need.
reduce the weight and velocity of bullets so they don't penetrate as much. A sub-sonic .22 has considerably less penetration than a 7.62 round.
If you're happy to bend the hard science a bit, some kind of 'healing factor' would work – perhaps a nano-tech you inject which will save you from a couple of shots? It would probably be less effective against swords as a slash wound would be larger and would overwhelm the nano-tech.