What am i missing in this little piece of code


function TOOL:LeftClick( tr )
    
local Pos1 = GetEyeTrace( ).HitPos + GetEyeTrace( ).HitNormal
local Pos2 = GetEyeTrace( ).HitPos - GetEyeTrace( ).HitNormal
    util.Decal("Smile", Pos1, Pos2)
end


Thats the code. For a STool that spawns decals much like the paint STool. Are there any people out there that know whats wrong. Oh the error is it says GetEyeTrace is a nill value. So yeah thanks in advance!

Well the wiki has code that does this in it, jusgt put it in the tool function, this should work inside that function because i just tested it and it worked.
[lua]
local Pos1 = tr.HitPos + tr.HitNormal
local Pos2 = tr.HitPos - tr.HitNormal
util.Decal(“Smile”, Pos1, Pos2)
[/lua]

Oh and you were calling GetEyeTrace() without self.Owner: infront, that was the problem.

–Edit–
Ok that made no sense, i meant the wiki code has an example in it which is basically what i said above.

Are you talking about the tool left click function or another one?

LeftClick function :stuck_out_tongue:

Yeah thanks all works well now

[editline]06:03PM[/editline]

To Further on with this what folder would i place custom decals in? I saw a decal folder tried putting one in there but it didn’t work any help?

[editline]06:26PM[/editline]

Grrr it’s annoying me. I got some decals from other maps and i put them in the decals folder and i even put it in the scripts folder in sandbox gamemode and it still doesn’t work!!! HELP please