change color on visible?

I’m trying to revive a old skeleton cheat and I tried making the skeletons colors change when the players are visible or not.


local function Skeleton(e)    
        if !e:Alive() then return end
		if GetConVarNumber( "Kittix_ESP_Skeleton" ) >= 1 then
        for k, v in pairs( skeleton ) do
                local sPos, ePos = e:GetBonePosition( e:LookupBone( v.S ) ):ToScreen(), e:GetBonePosition( e:LookupBone( v.E ) ):ToScreen()
                end
    end
	end
hook.Add("HUDPaint", "SkeletonESP", function()
        for k,v in pairs(player.GetAll()) do
                if v != LocalPlayer() then 
				Skeleton(v)
                end
        end

end)

I spent like 2 hours trying to do this.

I was using this


				if( Visible(e) ) then
                        drawColor3 = Color( 255, 255, 0, 255 );
                    else
                        drawColor4 = Color( 255, 0, 0, 255 );

TraceRay