How to minus energy per second of using sprint?

I added sprint to my game. I have energy bar too. But i want to minus 10 energy per second of using sprint.
How can I do that?
Please help me.

Your question has the same solution as this one. It can be solved with a Timer in a similar manner.

Thnaks, but I already done it by myself.
And without Timer.

But now, I’m doing regeneration.
And after energy is lower than 0.1 or sprint button is released WhileLoop starts with condition “BarEnergy < 1” and loop body which is adding to “Set BarEnergy” Value of “Bar Energy + 0.05”. And when in game I will do one of start loop conditions it will refull energy bar, but it is happening immediately. And I wanted to wait one second before adding another 0.05. So I added a Delay with duration set to one second, and I added that delay between WhileLoop and “Set BarEnergy”. But When I done one of start loop conditions, my game crashed and the Message Log said that infinite loop was detected. What should I have to do? How to repair this now?