How can I make Stamina deplete over time

I created a weapon overheat system that works fine, with heat building up everytime the player fires and reducing over time when he is not. I tried to do the same with stamina, starting full and depleting when the player is holding the sprint button and moving. My stamina bar starts full but doesn’t go down as I am running. I might have made a mistake switching the maths from heat building to stamina reduction but can’t put my finger on the problem.

Any help would be greatly appreciated!

post a picture of your script if you can that way we can try to just adjust it rather than build from scratch

Sorry I took pictures but forgot to add them!

I play tested a bit more and by changing the values of my variables I managed to make it work, but the changes to my stamina bar only happens after I release the sprint button for some reason, might not be calling my depletion over time at the right place, or the wrong way. On the same problem, if I run until my stamina is out, a fatigued text is supposed to appear next to the stamina bar. It does happen but the character doesn’t stop running until I release the run button first, then I can’t run anymore until the stamina goes full, that means my can run boolean turns false indeed but my functions don’t update properly.