Firstly, you should copy-paste your code using code tags from the toolbar ribbon.
Second, to fix your issue, you are setting playerAttack to true and then immediately setting it to false a few lines later, which is essentially instantaneous. Since you mention you want it playerAttack to equal false after the animation, you can call that function at the end of your animation, like on the last frame.
If you haven’t done that before, look up Animation Events for Unity.