Player attacking all enemies at once

Greetings, im doing a melee damage system, where the player attacks enemies, so i used a collision box on the player to detect every time an enemy approaches and save that enemy in a variable, so far so good
the problem is that when i attack a close enemy, the others that are far away also take damage, and that wasnt supposed to happen