RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 24 Feb 2016 10:06 PM |
while test.Value == true do for i = 30,0,-1 do text.Text = i wait(1) end end
i want the for function to work but only if the test.value is true and make it stop when its false please help |
|
|
| Report Abuse |
|
|
RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 24 Feb 2016 10:06 PM |
sorry I should have said more
this script works but if the test.Value turns to false, the countdown will still continue |
|
|
| Report Abuse |
|
|
Contrary
|
  |
| Joined: 08 Jan 2011 |
| Total Posts: 1306 |
|
|
| 24 Feb 2016 10:11 PM |
Well, the issue comes from the fact that the loop will execute if the value is "true", and it'll keep running what's inside until it's over. In this case, you have a for-loop... so that will have to finish before it checks if the value is "true" again.
Try something like:
for i = 30,0,-1 do if test.Value == true then text.Text = i end wait(1) end end |
|
|
| Report Abuse |
|
|
malachi11
|
  |
| Joined: 07 May 2008 |
| Total Posts: 2420 |
|
|
| 24 Feb 2016 10:11 PM |
A while loop only checks if it is still true after the loop is finished. In this case, after the countdown is done. You could do something like this:
while test.Value == true do for i = 30,0,-1 do if (test.Value~=true) then break --This will immediately cancel the for loop, then the script will go back to the while loop and end that too. end text.Text = i wait(1) end end |
|
|
| Report Abuse |
|
|
RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
| |
|