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

How can a script loop while a variable is true?

Asked by 4 years ago

Is there a way i can make it loop like a function while a variable is true?

2 answers

Log in to vote
1
Answered by 4 years ago

Here is a quick example. Sorry if it’s sloppy I’m on my phone.

Boolean example:

example = true

while example == true do — script here end

Value example:

example1 = 1

while example1 == 1 do — script here end

Ad
Log in to vote
0
Answered by 4 years ago

Be aware that I am not a professional scripter. But I'm totally sure this will work.

Use the "while true do" loop. for example:

while true do
    wait(5)
    i = true
    wait(5)
    i = false
end

while i = true do
    print("Five seconds has passed.")
end

This script will print "Five seconds has passed" to the output every five seconds. Just change all this a little, and voilà! You made your own game!

Answer this question