First off, welcome to the world of addon programming.
Secondly, bookmark these sites if you haven't already:
https://wowpedia.fandom.com/wiki/Wow..._customization
https://www.townlong-yak.com/framexml/live
This link points you to how you can get unit info which would be your target or mouseover etc..
https://wowpedia.fandom.com/wiki/API...me#GetUnitName
The following is an old post that asked the same question.
https://www.wowinterface.com/forums/...ad.php?t=55898
But .. I couldn't see UNIT_DIED or PARTY_KILL on wowinterface now so may be events that have been removed.
The other option is
https://wowpedia.fandom.com/wiki/PLA..._KILLS_CHANGED
But all it does is pick up a unit_id which you might be able to use to get the unit name using the function I mentioned above.
The problem though is whether your target changes between you killing the person and the event triggering and being acted on.
But good luck.