Energy Bar

For a while, I’ve been trying to make an energy bar in the game that can limit how long the character can run for. As the player runs, the energy bar will lower and when not moving, it will go back up. I’ve been looking for video tutorials and can’t find any. Would anyone mind helping me with this?