Drawing a halo around a entity when looking at it

Title pretty much just says it all
Just wanting to know how to make the Halo only show when a player is looking at it, so I assume we’d use GetEyeTrace in this situation but I’m not sure how to go about it.
My current code:


hook.Add( "PreDrawHalos", "AddHalos", function()
	halo.Add( ents.FindByClass( "spawned_weapon" ), Color( 255, 255, 255 ), 1, 1, 1 )
end )

[lua]
hook.Add( “PreDrawHalos”, “AddHalos”, function()
if (LocalPlayer():GetEyeTrace().Entity.HasHalo) then
halo.Add( {LocalPlayer():GetEyeTrace().Entity} , Color( 255, 255, 255 ), 1, 1, 1 )
end
end )
[/lua]

And where would I put my entity into that code? My entity is a: spawned_weapon

Just add ENT.HasHalo = true in spawned_weapon.lua

Thank you! Appreciate the help mate