I have a stamina system in my game and i want that everytime a player stops sprinting they need to wait 2 seconds for the stamina to regenerate. I made a separate function for it using a task.wait, it stops the stamina from regenerating and after two seconds it starts to regenerate and i spawned it whanever the player stops sprinting.
What’s the issue? If a player spams the left shift (the sprint input) sometimes it bypasses the wait and they do not need to wait those 2 seconds to their stamina to regenerate.
I tried using if statements inside the first function but it still manage to get bypasses, how can i fix that?