#Can I make loops that stop when something happens?
26 messages · Page 1 of 1 (latest)
yes
How can I make them
Depends on what you want to happen.
A property of an object to change?
:GetPropertyChangedSignal()
Else something like this works:
for i=1, 10, 1 do
if i==4 then break;
end
There are many ways to stop a loop.
Wait isn’t it like
—whatever
end
That's also another way of doing it.
I’m not really good with scripting either so don’t take my words seriously lol
local touched = false
script.Parent.Touched:Once(function()
touched = true
end)
repeat
task.wait(1)
print("Hello World!")
until touched
Trust the pros
What you've said is right.
:D
Thanks
that will start a loop based on certain condition
this starts the loop at the start of the script, but will break once a condition is met throughout the loop
it will also stop once the index reaches 10
local variable = false
while variable == false do
task.wait(15)
variable = true
end
the variable will become true after 15 seconds
when it becomes true this loop will stop
also specify which loop do u want?
for loop? while loop?
Thanks, I realised that.
So if the certain condition isn't met, the loop stops