I made a script to check who was responsible for your death or the death of another player / npc:
local Victim = {}
local module = {}
function module.New(caract)
local Data = {
["Agressor"] = nil;
["Time"] = 0
}
Victim[caract] = Data
end
function module.Delet(caract)
Victim[caract] = nil
end
function module.Get(caract)
return Victim[caract]["Agressor"]
end
function module.Set(caract,aggressor)
Victim[caract]["Time"] = 5
Victim[caract]["Agressor"] = aggressor
end
function module.DeletAgressor(caract,agressor)
for count = 1,5 do
Victim[caract]["Time"] = Victim[caract]["Time"] - 1
if agressor ~= module.Get(caract) or Victim[caract]["Time"] == 5 then
break
else
module.Set(caract,"")
end
wait(1)
end
end
function module.attackedPlayer(caract,aggressor)
module.Set(caract,aggressor)
module.DeletAgressor(caract,aggressor)
end
return module
The system saves the victim and aggressor using their Character as a reference, after 5 seconds without being attacked the system removes the aggressor, in case the aggressor changes or he attacks you again, the time resets to 5 again, that is, if you kill yourself in combat the aggressor will receive the kill