• TakeDamage gives nil error, but still proceeds to work.
    2 replies, posted
Timer Failed! [BleedingTimerHead][@addons/trade deal alpha sandbox gm test/lua/autorun/player_healthmanagment.lua (line 16)] [BlackSnow|3|STEAM_0:0:70942450] Lua Error: [ERROR] addons/trade deal alpha sandbox gm test/lua/autorun/player_healthmanagment.lua:17: attempt to call method 'TakeDamage' (a nil value)   1. unknown - addons/trade deal alpha sandbox gm test/lua/autorun/player_healthmanagment.lua:17 Any way to fix this? It seems to work when I shoot the head it just gives me the error which annoys me really bad. Code: hook.Add("ScalePlayerDamage", "BleedingManager", function(ply, hitgroup, dmginfo) damageammount = dmginfo:GetDamage() attacker = dmginfo:GetAttacker() if ( hitgroup == HITGROUP_HEAD ) then attacker:EmitSound("headshot-1.wav") ply:EmitSound("headshot-1.wav") dmginfo:ScaleDamage( 1.3 ) timerHead = damageammount/1 timer.Create("BleedingTimerHead", 3, timerHead, function() ply:TakeDamage(1) end) end And yes, I tried also doing ply:TakeDamage(1, attacker, ply) but still the same error.
Because it's running in server but causing error in client, you don't need that hook being part of client state, enclose it inside SERVER
Thank you kind sir! Works as intended now
Sorry, you need to Log In to post a reply to this thread.