player.try_get_killer

a.k.a. player.get_killer

When called on a player on the exact frame that that player died, this function returns the identity of their killer, if any. If the player died by their own hand, then they themselves are the return value.

When called on any other frame, even while the player is dead, this function does not return a value:

This function returns player. Calling this function without storing its return value in a variable is an error.

Example

for each player do
   if current_player.killer_type_is(guardians | suicide | kill | betrayal | quit) then
      --
      -- The player is dead.
      --
      global.player[0] = current_player.get_killer()
      global.player[0].score += 1
   end
end

See also