having trouble displaying damage dealt to mobs.

at first i thought of using the minecraft.custom:minecraft.damage_taken scoreboard and displaying the damage trough an invisible armor stand's name but the scoreboard only works on players. then i thought of using two dummy scoreboards: health_before_hit and health_after_hit. health_after_hit will have /execute store result score...data get entity health... and /execute store result storage...scoreboard players get @s health_after_hit. then, in the same function ill schedule another function one tick later to run another function with the storage and use macros to set health_before_hit to health_after_hit. then, in that one tick that they are different i could subtract health_after_hit from health_before_hit to get the damage, store it in storage, and use it in a macros function to set the armor stand's name. problem is that this stores every entity's health and, unless i reset it,(which then messes with the health_before_hit thing) it will just store dead entity's health too. i could probably fix it by doing a /execute unless entity... scoreboard players reset @s damage_after_hit and damage_before_hit but I'm sure there is a more elegant solution. if anyone knows it, i would appreciate it very much if you help me. thank you

Continue to help post