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

How would I make this stop at 0 and reset to 30?

Asked by
Uroxus 350 Moderation Voter
10 years ago

So ive been messing about with this for about half an hour.. The script is inside a text lable and works well, but when it gets to zero it goes to negative numbers, I dont want this. I need it to reset to 30 and the countdown notice to change.

Any tips on how I can adapt my script to do this? Thanks in advance.

while true do

script.Parent.Text = script.Parent.Text -1
wait (1.1)
end

3 answers

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago
while true do
    for i=30,0,-1 do
        script.Parent.Text=i
        wait(1.1)
    end
end

Counts down from 30 and displays it on the TextLabel. This part loops forever.

0
Thanks for your reply, But I need the countdown to start at 180 and go to 0 and then when it reaches 0 starts again at 30? I guess it was my fault not explaining it porpperly. Uroxus 350 — 10y
Ad
Log in to vote
0
Answered by
yurhomi10 192
10 years ago
repeat -- might be wrong uh..
script.Parent.Text = script.Parent.Text -1
wait (1)
until script.Parent.Text = 0

Log in to vote
0
Answered by 10 years ago

Try using it this way.

--script.Parent.Text = 30
Seco = 0

while true do
    Seco = Seco +1
    script.Parent.Text = script.Parent.Text -1
    if Seco == 30 then
        script.Parent.Text = 30
    end
    wait (1.1)
end

Answer this question