Why does surface.DrawLine work only when looking at an entity?

My function is working oddly, I’m using a HUDPaint Hook with a function that draws a line from LocalPlayer() to all players. The problem is, it seems to stop working when I’m not looking at a prop. Anyone know why?

Paste your code. Are you setting the draw color?

I haven’t set the draw color.


function StickmanView()

	for a, b in pairs (player.GetAll()) do 

		if b:IsPlayer() then
			if b != LocalPlayer() then

			local thehead = b:LookupBone("ValveBiped.Bip01_Head1")
			local joe = b:GetBonePosition(thehead):ToScreen()
			local me = LocalPlayer():GetPos():ToScreen()

			surface.DrawLine( joe.x, joe.y, me.x, me.y )

			end
			
		end

	end

end

hook.Add("HUDPaint","StickmanView", StickmanView)


you need to set the draw color ( surface.SetDrawColor ) before surface.DrawLine, otherwise it’ll use the previous used colour by anything ( which’ll probably be the player hud indicator )

Great, thanks to the smart people here.