Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Something automatically resets itself, need big help please?

Asked by 10 years ago

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.

2 answers

Log in to vote
0
Answered by
trogyssy 221 Moderation Voter
10 years ago

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.

0
In what way was it either? I scripted this myself. How is it obvious? pivot513 5 — 10y
0
And also, I need maxstam to be able to be edited, which is part of the script right there. It also needs to regenerate automatically which is also in the script. pivot513 5 — 10y
0
And also, I need decimals. Sorry I didn't put it all in one comment. pivot513 5 — 10y
0
provide the entire script please -_- trogyssy 221 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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

0
Thanks for the compliment, but I already set Stam's value earlier in the script, this is just a portion of a script. pivot513 5 — 10y

Answer this question