The following script only prints twice. I believe this is because once the condition is no longer met the loop no longer runs even when the condition is correct again.
01 | x = false |
02 |
03 | while x = = false do |
04 | print ( "x is false" ) |
05 | wait( 1 ) |
06 | x = true |
07 | end |
08 |
09 | while x = = true do |
10 | print ( "x is true" ) |
11 | wait( 1 ) |
12 | x = false |
13 | end |
My question is what would be the solution to make this go on forever? (as in printing x = true then x = false repeatedly instead of just once.)
The application which I am using it for is a game loop, but this shows the issue I am facing on a smaller scale.
Hey. If I see that correctly, you are trying to loop something. I would try to do it with a While true do.
My version of the script:
01 | while true do |
02 | x = false |
03 |
04 | while x = = false do |
05 | print ( "x is false" ) |
06 | wait( 1 ) |
07 | x = true |
08 | end |
09 |
10 | while x = = true do |
11 | print ( "x is true" ) |
12 | wait( 1 ) |
13 | x = false |
14 | end |
15 | end |