Raycasting in C++?

Hi! I don’t know if I’m doing this somewhat right or if I’m completely wrong but I wanted to know how I should go about this:
1.Should I shoot the raycast from the player class and just attach the gun.
2.Or should I implement raycasting in the gun’s actor class and call it from the character.

And for which ever option it would be nice if I can get an example cause I’ve tried implementing both ways and it doesn’t seem to work. Also, if you need me to include the ways I’ve implemented this I can only show option 1 cause I reset the code and I don’t wanna rewrite it again.
This is for Unreal Engine 4.27.2

And thanks in advance.