Is there a gun that doesn't need ammo? Where you could just pick it up and pull the trigger and it'll shoot without you needing to go buy bullets and load them into it.
gun is basically a method for transferring energy into an object and causing that energy to destroy the object.
you can't create energy from nothing. in normal gun, the energy comes chemical reaction and the carrier is bullet. in railgun, the energy comes from batteries, and the carrier is a metal shaft. in slingshot the energy comes from your muscles, and the carrier is stone.
I guess one could imagine solar-charged laser weapon, but that's not really a 'gun'. definitely not one that you would pick up and shoot.