Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can a script loop while a variable is true?

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

2 answers

✓ Accepted answer

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

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.