I tries using this code, but before it can even start, a pop-up thing says “Cannot read property ´start´ of undefined”. I dunno what to do I; I tried changing everything, but nothing seems to work.
Start getting in the habit now. You have to check if an enemy exists before you can attack it because if there is not an enemy present - even for one second - the code fails. It fails because you are instructing it to do something with an object that isn’t there. This is true for all objects (coins, potions, enemies, mushrooms, etc.).