Problem with Trace

So I’m trying to paint AGGRESSED and Able to attack player: on top of the player that is aggroed. But my trace isn’t working, what’s wrong with it? It basically only works when I look in a certain direction or when the players are looking at a certain direction. But, without the trace the thing shows up fine so I don’t know why the trace is screwing up. Any ideas?

[lua]
function PANEL:Paint()
for k, v in pairs( self.listContents ) do
if ValidEntity(v.entity) then
local tracedata = {}
tracedata.start = LocalPlayer():GetShootPos()
tracedata.endpos = v.entity:GetShootPos()
tracedata.filter = LocalPlayer()
local trace = util.TraceLine(tracedata)
if trace.HitNonWorld then
local pos = v.entity:GetShootPos():ToScreen()
draw.SimpleText(“AGGRESSED”, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 8), Color(255,0,0,255), 1, 0)
draw.SimpleText("Able to attack player: " … v.canattack, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 5), Color(255,255,255,255), 1, 0)
end
end
end
end
[/lua]

Alright here’s the whole code for the Panel.

[lua]
local PANEL = {}

function PANEL:Init()
self.listContents = {}
self.tableUpdate = CurTime() + 1
self.panelParentPadding = ScrW() / 256

self:SetPos( 0 , 0 )
self:SetSize( ScrW() , ScrH() ) 

self:SetVisible( false )
self:MoveToBack()

end

function PANEL:Paint()
for k, v in pairs( self.listContents ) do
if ValidEntity(v.entity) then
local tracedata = {}
tracedata.start = LocalPlayer():GetShootPos()
tracedata.endpos = v.entity:EyePos()
tracedata.filter = LocalPlayer()
local trace = util.TraceLine(tracedata)
if trace.HitNonWorld then
local pos = v.entity:GetShootPos():ToScreen()
draw.SimpleText(“AGGRESSED”, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 8), Color(255,0,0,255), 1, 0)
draw.SimpleText("Able to attack player: " … v.canattack, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 5), Color(255,255,255,255), 1, 0)
end
end
end
end

function PANEL:Think()
if (next(self.listContents) == nil) then
self:SetVisible( false )
end
if (CurTime()>self.tableUpdate) then
self.tableUpdate = CurTime()+1
for k, v in pairs(self.listContents) do
v.timeleft = v.timeleft - 1
if v.timeleft < 1 then
self.listContents[k] = nil
end
end
end
end

function PANEL:AddEntry( ply, TimeLeft, CanAttack )
if ply:Nick() == LocalPlayer():Nick() then return end
if TimeLeft == -1 then
self.listContents[ply] = nil
return
end
if self.listContents[ply] == nil then
self.listContents[ply] = {}
end
self.listContents[ply].name = ply:Nick()
self.listContents[ply].timeleft = TimeLeft
if CanAttack == “Yes” or CanAttack == “No” then
self.listContents[ply].canattack = CanAttack
end
self.listContents[ply].entity = ply
self:SetVisible( true )
end

function PANEL:ResetEntries()
self.listContents = {}
end

vgui.Register(“gms_AggressionTimerOntopPlayer”,PANEL, “Panel”)
[/lua]

Thank you Gbps for solving my problem.

[lua]
function PANEL:Paint()
for k, v in pairs( self.listContents ) do
if ValidEntity(v.entity) then
local tracedata = {}
tracedata.start = LocalPlayer():GetShootPos()
tracedata.endpos = v.entity:LocalToWorld(v.entity:OBBCenter())
tracedata.filter = { LocalPlayer(), LocalPlayer():GetActiveWeapon(), v.entity, v.entity:GetActiveWeapon() }
tracedata.mask = MASK_PLAYERSOLID
local trace = util.TraceLine(tracedata)
if trace.Hit == false then
local pos = v.entity:GetShootPos():ToScreen()
draw.SimpleText(“AGGRESSED”, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 8), Color(255,0,0,255), 1, 0)
draw.SimpleText("Able to attack player: " … v.canattack, “TabLarge”, pos.x, pos.y - (self.panelParentPadding * 5), Color(255,255,255,255), 1, 0)
end
end
end
end
[/lua]