How can i fix a skill which uses 20 mana and works fine until the very last 20 mana remaining which then it skips the attack ?

I suggest you try this: after the consume mana function only have 2 print nodes, one on true and another on false. Disconnect everything else. If the print on true executes 5 times (5 clicks) and the one on false executes on the 6th click and after means the problems is elsewhere.

Let me know how it goes.