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 ?

If you only do the check once like the image above then the very last consume souldnt be a problem. If there are no other branches checking the available mana then right know I think this is your main issue.

This is all taking into consideration the start value of mana is 100.0 and the skill costs 20.0.