Thank you again Minor, I see that it does work. Could you explain in a little more detail how this part of your code works though?
Set distance to distance(attack_detect.X, attack_detect.Y, attack_detect.X, enemy_hitbox.Y)
I assume the first two entries retrieve the X and Y coordinates of the player's attack box, but why do you use another X command for the attack box with the Y for the enemy hitbox? I'm not questioning that your method works, I just don't quite understand exactly what's happening with it.
Thanks for your time so far!
edit: Oh, I see that function does require x1, y1, x2, y2, sorry. If you have time though, could you still explain what measurements are taking place? I'm more of a graphics person than a math person.