What would I use for this "stamina script

I’m just wondering if i were to make a script, in this case a stamina script, where if a player doesn’t jump for like a second or two the stamina starts going back up really fast. what would i use to delay the stamina regeneration. I thought of using a value and having it constantly count down, stopping it at zero and using some while loops and adding time when a player jumps but this seems messy and i’m wondering if anyones figured out a better option

1 Like

For stam regen add a coroutine that has a while debounce false loop that counts down the time before regen starts and then regens after debounce finishes, then simpily update the coroutine when debounce is activated to keep it on the correct cycle.

Another option would be to just have a remote event in another script that fires when the player has stopped moving for a few seconds. Then you would just connect a function that does the stamina regen to that event.

1 Like