The TDI.Attacker represents the attacker, it can be either a cPlayer object or a cMonster descendant. So you should first test it with the IsA() function and if it is a cPlayer, then cast it:
function OnTakeDamage(a_Receiver, a_TDI) if ((a_TDI.Attacker == nil) or not(a_TDI.Attacker:IsA("cPlayer"))) then -- The attacker is not a player return end -- Get the true cPlayer object out of a_TDI.Attacker: local Player = tolua.cast(a_TDI.Attacker, "cPlayer") -- Just show off what we can do with it: LOG("Player " .. Player:GetName() .. " attacked a " .. a_Receiver:GetClass()) -- If the player attacked a cow, kick them if (a_Receiver:IsA("cCow")) then Player:Kick("The cow is a sacred animal") end end