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
local float = true
while float == true do
    gui.back.title:TweenPosition(UDim2.new(0.114, 0,-0.151, 0),"Out","Quad",1,true)
    wait(1)
    gui.back.title:TweenPosition(UDim2.new(0.114, 0,-0.101, 0),"Out","Quad",1,true)
    wait(1)
end

gui.back.button.Activated:Connect(function()
 float = false
end
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:

while wait() do

end

print("This will NEVER print because of that while loop")

Instead this would be much better:

print("Now we can print what we want and run the loop")
while wait() do

end
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

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

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

Answer this question