As I think I understand it:
Every 4 seconds might be half way through its "loop" when you are checking so instead of waiting 4 seconds you will only wait the remainder of the 4 seconds.
So how about setting up a global variable (gvManaTimer ?) and increasing this every 1/10th of a second.
then you reset GVManaTimer at the correct time and wait for it to be +40 before you increase you actual mana ?
so you will end up with something like
make GlobalVariable called gvManaTimer
every 0.1 seconds : increase gvManaTimer
I've used some mana
reset gvManaTimer to 0
is gvManaTimer >40 (ie it's 4 seconds plus since I last reset gvManaTimer)
YES ? : add one to mana (if mana is less than it should be)
: also reset gvManaTimer to 0 to restart its 4 seconds again
this will still have the same problem of maybe starting its loop during the every x seconds but as the time is small then probably not noticeable.
Maybe 0.1 is too short a time - every 0.25 or 0.5 or even 1 second updates ?