How to make a character do dmg by pressing a button?

I am making a 2d game and I have been trying for hours at this point to make my character deal dmg to an AI and I just don’t seem to be able to do it
I have set a hp for the AI and a hitbox and a hitbox for the Character but when i press the button to deal dmg it either takes my own health or it doesn’t work