Hi, I am trying to add some fairly basic functionality to my server. However, I am having trouble using the arguments in a function that runs on PlayerDeath.
For example, the following code from here does not even work correctly:
function sayThatName(victim,inflictor,killer) //Use the same arguments as the original function you're hooking to victim:PrintMessage(HUD_PRINTTALK,killer:Nick().." killed you! ") end hook.Add("PlayerDeath","Inform Murder Victims",sayThatName)
Specifically, when a player dies and the function is called, the following error occurs twice:
[ERROR] lua/autorun/server/test.lua:2: attempt to call method 'Nick' (a nil value) 1. fn - lua/autorun/server/test.lua:2 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 3. TakeDamageInfo - [C]:-1 4. unknown - gamemodes/terrortown/gamemode/player.lua:1083
Any suggestions? Are the function arguments nil for some reason? (I’m unfamiliar with Lua)