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

[CLOSED]Why isn't the value that the script is in slowly decreasing?

Asked by 9 years ago

I have it so the value that the script is in will go down 1 ever 2 seconds, and it worked outside of the player but as soon as i made it go inside of the player as a leaderstat, it doesnt work.

repeat
print("going")
    script.Parent.Value = script.Parent.Value - 1
wait(0.5)
print("gone")
until 9 + 10 == 21

I have fixed the problem, instead of making the script go inside of the value, i made it edit it instead! here is the finished and working script!

repeat
print("going")
    script.Parent.Parent.Parent.Air.Oxygen.Value = script.Parent.Parent.Parent.Air.Oxygen.Value - 1
wait(2.5)
print("gone")
until 9 + 10 == 21

Thank you!!!

2 answers

Log in to vote
0
Answered by
Xetrax 85
9 years ago

1: Are you aiming for an infinite loop? because 9 + 10 will never equal 21, if that is the case, use a While loop instead while true do print("blah") wait() end, if not then your output will look like going gone going gone going gone ...etc.

And what do you mean by "i made it go inside of the player as a leaderstat"?

0
1) yes, i have "going" to represent that the script loaded succesfully, and "gone" to represent that the script is about to repeat (because 9 + 10 will never equal 21) yogipanda123 120 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You should use a while loops or should say "i would"

local Number  = script.Parent
while wait(2) do    -- Waits two seconds and then does this.

    print("going")
        Number.Value = Number.Value - 1 -- Subtracts number by 1
    wait(0.5)

    if Number.Value >= 21 then -- If Number is greater then 21 it will print "gone"
        print("gone")
    end
end

Hope this helped.

Answer this question