how to detect wich mob a player hit while holding a custom item?

i want to execute a function as the mob hit every time i hit him with this custom weapon

Continue to help post