Could be from an old issue of Asimov's Science Fiction. 80s to early 90s.
There's a recent story (2008) which won a hugo, "The Ray-Gun: A Love Story", about a sentient raygun found by a kid.
The story is about an unpopular teenage boy who finds an alien ray gun in the forest. Although he does not do much with the gun contemplating its design or use, and handling the ray-gun when alone, gives his life more direction and purpose. The story has some elements of "coming of age" stories in that it follows an adolescent becoming an adult, PhD student, and ultimately finding love. The ray-gun played a role in the direction of his life in all these things. However, in the end the ray-gun itself is abandoned as too dangerous or no longer needed.