You’ll most likely want to use “hit.point” to determine where your laser should be aiming. Assuming you’ve centered the beam in its parent properly, you could probably also just use Transform.LookAt(hit.point) to get it to rotate and aim at the exact point it hits the target.
What you are trying to do is more difficult than you probably expect.
Raycast from the center of the screen to find out the point that was shot.
Base the damage done based on the raycast from the center of the screen
Instantiate the rail effect from the tip of the gun, point it at the point that was shot using LookAt(hit.point) as the prior commented suggested.
It’s going to look strange that the rail effect won’t align with the gun itself. You either need a rail that is visually disconnected from the gun, such as a projectile that moves over time, or move the gun to the bottom center of the screen
Why should he do that, specifically? He’s already performing the raycast from the camera’s position, directly forward. He’s not trying to raycast to the mouse position or anything. How would the approach you’re suggestion change anything?
The raycast isn’t the problem. The problem is what he’s doing with the result of the raycast.