hi!! i think your "do every x seconds" line is causing the game to crash! loops are very dangerous stuff and you have to remember that //every tick// they must execute and exit. this means your loop is waiting a whole second before decrementing--and finding that its condition is still true--is unable to exit--and? im guessing probably halts every other process and causes it to crash while executing this decrement every second. my suggestion would be to scrap the loop entirely and create an isDecreasing boolean. once (energy >= maxEnergy) is true, turn isDecreasing on and create a timer or if statement underneath a check for isDecreasing to decrement the energy. once energy reaches 0, isDecreasing will be turned off. this probably needs some tweaking but this will be a much more stable way for you to decrement the energy!
aa fantastic!!! i'm glad you figured it out! altho i do want to say even if you did all of the energy decremented at once the "once a second" part would stall the loop from exiting immediately which would prevent the tick from being able to finish up and run anything else. wait/timer commands aren't meant to be inside loops 3: