How would I prevent Stamina regeneration after using Stamina

Hi! I currently have a basic stamina system and a test weapon. This weapon consumes 18% of my stamina.
The issue is that my stamina is coded to refill when it’s not at full (something I looked over) and I realize now I can’t think of any way to detect when it’s “consumed.”

https://cdn.discordapp.com/attachments/826176290913517610/826176365702938624/Desktop_2021.03.29_-_15.29.07.03.mp4

My Code (focusing the regen part)
while true do
	game:GetService('RunService').RenderStepped:Wait()
	if not sprinting then
		if not regenCooldown then
			regenCooldown = true
			wait(1.25)
		else
			stamina.Value = math.clamp(stamina.Value + 1, 0, 100)
			wait(0.028)
		end
	end
end```

Thanks for any help!

You could insert a bool value into the player using the player added event. Then when they use the tool, set the bool value to true. Then wait like 1 second and set the bool value to false. Then on your regen script, just check if the bool value is set to false.

2 Likes

That sounds like something that could work, I’ll give it a try.

1 Like