how to attach gun to character without arms / mesh?

I don’t believe you HAVE to use sockets, but you can. Sockets are generally a visual thing you apply to a mesh. I believe you can spawn sockets in without a mesh but I havent tried it.
If you do a attachtocomponent or attachtoactor, it will keep whatever xyz coords you spawned it in. so if you spawn at 0,0,0 then do an attach, well that is now attached dead center to your other pawn. if you attach 50,0,0, well now its always gonna be x+50 compared to your pawn/actor.

if you dont know what xyz to use, you can use the unreal engine editor. Drag your item in the editor and “attach it” to your camera (if you have on already spawned in the word/editor)
then move it where it should be (if you have your pawn/actor selected and it has a camera, it should create a first person preview though the camera) move the weapon where it needs to be so the preview window looks good to you. then notice the x,y,z numbers. Use those numbers for you code when you spawn it in, then do the attach to actor/component, whatever you ended up attaching to in the unreal editor. hope that makes sense.