Tried to access value HitPos, a userdata value

Hello, ive been trying to create a small clientside script to check whatever im aiming at’s class name.

this is my code so far
[lua]
function EntityOutput()
ply = LocalPlayer()

traceRes = ply:GetEyeTrace()
if not(traceRes.Entity:IsValid()) then return end;
local Position = traceRes.HitPos():ToScreen()
draw.DrawText(traceRes.Entity:GetClass(), “BudgetLabel”, Position.x, Position.y, Colour(0, 0, 150, 255))
end

hook.Add(“Think”, “Output1”, EntityOutput)
[/lua]

But i get this error:
Hook ‘Output1’ Failed: [lua\classoutput.lua:6] attempt to call field ‘HitPos’ (a userdata value)
When aiming at an entity, the loads fine from the console though.

Any ideas?

EDIT:
God damn it, Ignore this thread please, I forgot that you dont use () when you call a field.

traceRes.HitPos()

It’s not a function. Remove those two parentheses.

Okay, I fixed all the typo’s so the sscript runs fine, no errors pop up when eyeing over an entity, but nothing happens.
Its supposed to draw a text, but nothings happens.
Wierd

You need to do the drawing in a **[Gamemode.HUDPaint

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.HUDPaint)** hook.

So I tried this code and the same error.

[lua]
function EntityOutput()
ply = LocalPlayer()

traceRes = ply:GetEyeTrace()
if not(traceRes.Entity:IsValid()) then return end;

pos = traceRes.HitPos:ToScreen()

draw.DrawText(traceRes.Entity:GetClass(), “BudgetLabel”, pos.x, pos.y, Color(0, 0, 150, 255), 1)
end

hook.Add(“HUDPaint”, “Output2”, EntityOuput)
[/lua]

You have misspelled EntityOutput in your hook.Add call.

Facepalm Thanks a lot.