Im working on making a stamina script where it always checks (in a span of 3 seconds) if the stamina has changed or not. If it hasnt, then it will gradually increase until it detects it is decreased again.
Here is my script:
01 | while wait(. 167 ) do |
02 | if c:FindFirstChild( "Stamina" ) then |
03 | local stamina = c:FindFirstChild( "Stamina" ).Value |
04 | spawn( function () |
05 | delay( 3 , function () |
06 | if c:FindFirstChild( "Stamina" ).Value = = stamina and stamre = = false then |
07 | stamre = true |
08 | else |
09 | stamre = false |
10 | end |
11 | end ) |
12 | end ) |
13 | if stamre = = true then |
14 | c.Stamina.Value = c.Stamina.Value + 1 |
15 | end |
16 | end |
17 | end |
And it isnt working too well. Can someone help fix it up for me? Thanks
01 | local staminaValue = --Put value here |
02 |
03 | function Increase() |
04 | --Code to increase stamina over 3 seconds here |
05 | end |
06 |
07 | lastStam = 0 |
08 | while wait( 3 ) do |
09 | if staminaValue.Value > = lastStam then |
10 | Increase() |
11 | end |
12 | lastStam = staminaValue |
13 | end |
Short and simple. It checks if the stamina is going down every 3 seconds and if it's not then it will increase. If it is then it won't do anything. Comment if you need further assistance.