I need help with stamina mechanics!

I want to make a mechanic where you have energy and when you move you lose some energy (movement meter) but when you’re not moving you gain energy (5 per second) and the max amount of energy you can have is 100 (inventory manager) but I do not know how to make the player gain energy when they’re not moving! what do I do?

Okay! So I know how to do this but it does take some explaining, so I’m gonna link the YouTube tutorial I used to learn!
YouTube tutorial
I hope this is helpful!

I found another tutorial, so use this if you want tohttps://www.youtube.com/watch?v=pTOnDWC7ok4