If you get a good one (the mechanical part Gabe mentioned) and you are capable, you'll be able to shoot good groups (ammo can still be a factor, too.)

Not all guns are equal. Not even if they are the same brand/model/caliber.

My 3.8" XDM 9MM shoots better groups than my 5.25" XDM 9MM Competition model. Not just for me, but for the other 3 or 4 people that have shot both side by side on the same range day. Everyone likes the 3.8" gun better.

My CZ P07 .40 S&W shoots better groups than my CZ P09 .40 S&W. It just does. My CZ P07 9MM shoots better groups than any other center fire semi auto pistol I've ever shot.

Rifles are the same way. You may be able to change ammo to get a gun to shoot better groups. Changing sights might help you if you have issues "seeing" that front sight.

For what it's worth, I've had good luck with Federal 115 grain FMJ 9MM ammo. I mostly shoot my reloads, but the Federal 115 FMJ shoots darn good in my P09. It's not real expensive for range ammo either. I just bought a 100 round box today at Walmart for $18 and change. Not much more than the Tula someone mentioned.

I don't shoot a Glock anymore (they live in my safe now) but if the Glock trigger Gabe sells is as good as the AR15 trigger I got from SI a year or so back they are darn good triggers. I have mine in an 18" AR15 build and I let my youngest son shoot it awhile back. He said two things after he finished up with it. "It shoots pretty good." And, "It's got a nice trigger."

Very few "out of the box" guns are as nice as one is after you've spent some time/money putting some better parts in it to upgrade the fit of the parts, the sights and trigger. It's just the way it is. No matter how much money you put in it, the first time you save your life, or a family member's life - it's worth every dollar you spent on it.