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

How do I make my while loop constantly check?

Asked by 6 years ago
Edited by Goulstem 6 years ago
local stli = game.Workspace.Lights.Stage.Value
local c = 1
while c < 10 do
    print("run")
    wait(.2)
    if stli == true then
        if c == 1 then
            print("okhand") 
            c = 0   
    elseif stli == false then   
        if c == 1 then  
            print("notokhand")  
            c = 0   
        end 
        end 
    end 
end

There's a folder with the boolean in the workspace. All it will print in the console is one "notokhand" and then no more.

Any help is greatly appreciated, thanks ^^

0
well, thats because you have both if statements to go off if the value equals 1. However, the moment you have that happen, its set to 0. So, the c value would equal 1, change to 0, then the loop will endlessly run without any output. My suggestion; change the while to For, and make a For loop. its a loop that increments itself overtime. http://wiki.roblox.com/index.php?title=Loops#For User#19492 0 — 6y

Answer this question