Else if statment mistake from beginner

Below this summary I have attached two images. One with good code and one with bad code. After following the tutorial for the course I had an issue where my audio overlapped itself while I held down the Space key or LeftShift key. Both of which I was using for the same effect, just wanted to setup different controls for player preference, using my limited knowledge and research. Knowing where the bug was located somewhere in my code I knew I could come back to it. Without getting bothered by this issue I pushed forward in the course where multiple audio files are used. This is when I started tearing apart my code trying to figure out the bug.
I did not close out the “}” properly and could not use multiple inputs with my method. I will revisit the idea in the future, most likely to setup settings where a player can choose their own keybindings. I hope this issue may help other people like me in writing their own code.

The Bad code:

The good code:

Privacy & Terms