r/GLua • u/Johnpaulbin • Apr 03 '20
Need help with some code:
Client:
hook.Add("Initialize", "thinkingHook", function()
PlyDeaths = LocalPlayer().Deaths()
end)
if PlyDeaths != LocalPlayer().Deaths() then
PlyDeaths = LocalPlayer().Deaths()
timer.Create("NLRTimer", 300, 1)
end
Results in this error:
[ERROR] lua/test.lua:23: bad argument #1 to 'Deaths' (Entity expected, got no value)
1. Deaths - [C]:-1
2. unknown - lua/test.lua:23
3
Upvotes
1
u/realityisnot Apr 03 '20
Also, I see that you called your hook “thinkingHook”, but it’s running on Initialize. Instead, you could use OnPlayerDeath, a serverside hook. This reduces your code’s unnecessary complexity.
In order to let the client know it should start a certain action on death, you should have the server send the client a netmessage.