Get trace distance from an entity

I’d like to get the trace distance from an entity. So for example,

if LocalPlayer():GetEyeTrace().HitPos is within 100 of LocalPlayer():GetEyeTrace().Entity && ent:GetClass() == "spawned_weapon" then
------code here------

Any ideas? Couldn’t find anything through searching…

Appreciate any help!

You want the linear distance from the player to what the player is looking at?

print( LocalPlayer():GetPos():Distance( LocalPlayer():GetEyeTrace().Entity:GetPos() )

Is basically what you want. Obviously just check that the eye trace entity is valid and whatever else you’d like to check, but that’s the code.