I have a number value that is constantly being edited by another script, being shown later. When I try to subtract from the number value, it automatically corrects itself to what it was before; for example if the number value is 50, if I do 50 - 6 it displays 44 for a split second, and then it reverts back to 50. I suspect this script of the problem, but I don't know why this is causing it.
(Note: Maxstam is another number value that is supposed to be the limit of stam, so that if stam goes over maxstam it becomes maxstam, for example maxstam is 100, if stam is set to 106 it will go back to 100)
for i=1,math.huge do wait(0.01) maxstam.Value = (90 + ((tonumber(sta.Value))*10)) --Sets maxstam's value if stam.Value >= maxstam.Value then stam.Value = maxstam.Value --If stam goes over maxstam it adjusts to maxstam end if stam.Value <= 0 then --If stam is less than 0 stam becomes 0 stam.Value = 0 end if stam.Value <= maxstam.Value + 1 then stam.Value = stam.Value + (maxstam.Value/3000) --Stam automatically regenerates itself every end -- 0.01 seconds if player.Race.Value == "Skypian" then sped = spd.Value*10 --This part is unrelated player.Torso.LowGrav.force = Vector3.new(0,6000 + sped,0) end end
Please help, I've been stuck on this for a while now.
The first thing I'd do is if you don't need to use decimals for the value, change it into a ConstrainedIntValue or a DualConstrainedIntValue so the maxstam is unnessecary.
while wait(0) do --just use a while loop, the for loop will eventually end, and that's unnecessary maxstam.Value = (90 + ((tonumber(sta.Value))*10)) --Sets maxstam's value if stam.Value >= maxstam.Value then stam.Value = maxstam.Value --If stam goes over maxstam it adjusts to maxstam end if stam.Value <= 0 then --If stam is less than 0 stam becomes 0 stam.Value = 0 end if stam.Value <= maxstam.Value + 1 then stam.Value = stam.Value + (maxstam.Value/3000) --Stam automatically regenerates itself every end -- 0.01 seconds if player.Race.Value == "Skypian" then sped = spd.Value*10 --This part is unrelated player.Torso.LowGrav.force = Vector3.new(0,6000 + sped,0) end end
Btw, it's obvious you didn't script this. Be honest and say it was scripted for you/taken from a freemodel next time.
Wow thats one complex script but this is what I THINK I think you didn't set the Stam's value in the beginning so it couldn't do anything about the stam or that the regeneration is too fast