GetEyeTrace and healing

ok i am trying to heal the player i am looking at
my attempt
[LUA]
local eye = LocalPlayer():GetEyeTrace()
if eye.Entity:IsPlayer() then eye.Entity:SetHealth(100) end
[/LUA]

Did you get any errors?

[ERROR] addons/advheal/lua/autorun/sv_init.lua:35: Tried to use a NULL entity!

  1. Activate - [C]:-1
  2. func - addons/advheal/lua/autorun/sv_init.lua:35
    3. unknown - lua/includes/extensions/net.lua:32

Try and check if the player isValid first before initiating anything on the player.

ops that was the wrong error there was non

[editline]2nd October 2016[/editline]
[LUA]
net.Receive(“HealPlayer”,function()
if SERVER then
if eye.Entity:IsPlayer() then eye.Entity:SetHealth(100) end
end
end)
[/LUA]

IsPlayer checks for validity as well.

[editline]2nd October 2016[/editline]

Post your net.Send code and where you’re placing all of this file wise.

‘eye.Entity’ makes no sense in this context.

Neither does if SERVER, and the whole point of a net.Send makes no sense in this code as you can eyetrace server-side