You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
A less buggy stamina script
- What is the issue? Include screenshots / videos if possible!
For some reason, whenever it’s recovering some stamina it works fine but when it’s about to go back to 100 (the maximum), it takes longer than the others to iterate. and also when it’s depleting the stamina, it somehow doesn’t reach 0. it stops at 1
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
My stamina script is fairly different than others so it wouldn’t compare.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
My stamina script works when you only walk and does not need to press a button to “sprint” like the others. just when walking or interacting with “wasd”.
in a local script:
local player = game.Players.LocalPlayer repeat task.wait() until player.Character local char = player.Character local Humanoid = char:WaitForChild("Humanoid") local stamina = 100 stamina = math.clamp(stamina, 0 ,100) while task.wait(0.1) do if Humanoid.MoveDirection.Magnitude > 0 and stamina > 0 then repeat print("walking " .. tostring(stamina)) stamina -= 1 task.wait(0.05) until Humanoid.MoveDirection.Magnitude == 0 or stamina <= 0 elseif Humanoid.MoveDirection.Magnitude == 0 and stamina <= 100 then repeat print("not walking " .. tostring(stamina)) stamina += 1 task.wait(0.05) until Humanoid.MoveDirection.Magnitude > 0 or stamina >= 100 end end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.