Linetrace Length?

I’m trying to make a Third Person Shooter, and I want to make the crosshair larger or smaller depending on how far the linetrace from my gun goes (like in PUBG). is there a way to get the distance the linetrace travels before it hits something?

If you want to know how fare the object is that you will hit you’ll have to do a linetrace for that too, and get the distance. (this is the distance between the trace start and the point of impact)