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 4 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 — 4y
0
Just use break lol. Destroyer1234x 52 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 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 — 4y
0
Thanks matey FallenZalio 99 — 4y
Ad
Log in to vote
1
Answered by
dreamy67 135
4 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