Is it possible to stop a while from a script to a module?

As the name suggests, I am wondering if it is possible to stop a while loop (that’s in a module) from a script. I’ve attempted to do so but my tries were only futile. Any help would be appreciated!

It depends on how your loop is structured and what it’s doing, or what you mean exactly by “stop”.

It could be as simple as a loop over a condition, or breaking on a condition, such as:

while condition do
    -- stuff
end

and then exporting a function to change the condition variable within the module.

2 Likes

What I meant by stop was breaking on a condition through a boolean that is sent through the function being fired from the script (in the parameters).

Seems like I solved my own problem, but only because you made me realize that I could just add another function in the modulescript that returns a boolean false to stop the loop. Thanks for that!