Can anyone help me with the stamina script I made won’t let players stamina go up
if Sprinttoggled and Humanoid.MoveDirection.Magnitude > 0 then
stamina = stamina - 1.3
elseif Sprinttoggled == false and Humanoid.MoveDirection.Magnitude == 0 and Energyboost == false then
stamina = stamina + 0.7
end
Ok, try this:
When this code is run in the while loop, print Sprinttoggled, then print Humanod.MoveDirection.Magnitude, and then print Energyboost.
Printing is useful because you can check what the values of the variables are. By looking at what is print when you aren’t gaining any stamina, you can see what value is off/isn’t what it should be and then you can investigate it further.
Example:
print(`Sprint: {Sprinttoggled}`)
print(`MoveDirection magnitude: {Humanoid.MoveDirection.Magnitude}`)
print(`Energyboost: {Energyboost}`)
if Sprinttoggled and Humanoid.MoveDirection.Magnitude > 0 then
stamina = stamina - 1.3
elseif Sprinttoggled == false and Humanoid.MoveDirection.Magnitude == 0 and Energyboost == false then
stamina = stamina + 0.7
end
Please do this so we can easily debug the code and find out the issue
I just figured it out while you were typing I went back to Roblox studio and found out the issue when I implemented the energy boost thing that’s when the stamina broke
Yeah, I was right after I removed the energy boost thing the stamina worked perfectly,
Now I have to figure out how to implement the energy boost without stamina breaking.