I want to loop several lines of code based on weather a variable is true or false, but i don’t know how to do so, and the for loops seem to be for getting table values. How would you loop something like this?
Look up a “while” loop. You execute code while a variable is true and exit the while loop when that variable is false. Or you can execute a while loop as lone as a variable is less than a certain value.
--Set Variable to 1 or 0, signifying true or false
Variable = 1
--What value you want
WantedValue = 1
if(Variable==WantedValue) then
print("Variable is at desired value")
end
@austinmccoy But he wanted to loop code, not just an if statement.
@Mr_Ninja Do you mean loop a few lines of code a set amount of times if a variable is true, or loop a few lines of code while a variable is true? (Keep in mind that if you loop a few lines of code while a variable is true, the viewport won’t update.)
I used the while loop that dave1707 suggested, it works and my app is working, other than a few ui changes that I’m making still
@SkyTheCoder Ahh, missed that part. Here is a revision:
--Set Variable to 1 or 0, signifying true or false
Variable = 1
--What value you want
WantedValue = 1
while(Variable==WantedValue) do
-----Your code....
end