What I did was make a Boolean value so a script could interact with another. But how can I use that to my advantage in stopping a while true do script in the middle of the piece of code at any point in time?
COMMUNITY QUESTION
How do I stop loops using another script?
2 answers
You're explicitly stating that something should only done while this is true, so that means you shouldn't be using a while true loop, you should be using an actual condition:
while someCondition do
-- (your loop)
end
Alternatively, as M39a9am3R suggested, you could use a break to emulate this:
while true do
if not someCondition then
break -- Stop the loop ("break" the loop)
end
-- (your loop)
end
you can stop it by using another script and putting a Bool Value in the script thats going to stop it. Have the script change it by doing script.stop.Value = true or what ever you want it to be.
Then in the one you want to stop, just add this to the top
if not game.Workspace.stopScript.stop.Value then
while true do
--stuff
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Just do, "if (value) == false then break end", replace value to the boolean.