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

while loop will not break when set to false ?

Asked by 5 years ago
01local float = true
02while float == true do
03    gui.back.title:TweenPosition(UDim2.new(0.114, 0,-0.151, 0),"Out","Quad",1,true)
04    wait(1)
05    gui.back.title:TweenPosition(UDim2.new(0.114, 0,-0.101, 0),"Out","Quad",1,true)
06    wait(1)
07end
08 
09gui.back.button.Activated:Connect(function()
10 float = false
11end
0
use spawn(function() to thread the loop... duh or coroutines.. This is so that line 9 is able to work, the loop is not allowing that to happen, with spawn(function() it will work greatneil80 2647 — 5y
0
Just use break lol. Destroyer1234x 52 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This is because you have to do the binding first then the while loop:

1while wait() do
2 
3end
4 
5print("This will NEVER print because of that while loop")

Instead this would be much better:

1print("Now we can print what we want and run the loop")
2while wait() do
3 
4end
0
^ or you can spawn the function karlo_tr10 1233 — 5y
0
Thanks matey FallenZalio 99 — 5y
Ad
Log in to vote
1
Answered by
dreamy67 135
5 years ago

Your code never reaches

1gui.back.button.Activated:Connect(function()
2    float = false
3end

because it gets caught in the loop. Move your connect function before the loop starts.

Answer this question