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

How do you make a function stop, even if it's a loop script?

Asked by 4 years ago

if I were to do something like

local function test() while true do print("testing") wait() end end

what would be a way I could make the function stop? so it doesn't call the function and stops printing

1 answer

Log in to vote
0
Answered by 4 years ago

Before I answer, it would be helpful to put your code in Lua, instead of typing it out.

So regarding your question, you can use "break" to stop while true do loops. E.g.

local function test()
    while true do
        print("testing")
        break
    end
end

If you have any problems please comment on this post.

0
I forgot to add how do you make the function stop from outside the function? XxrockatackxX -1 — 4y
0
Well, it would be the same code as the initial answer. A function will only fire when test() is put on the code, so "break" will stop the "while true do" loop thus the function will finish. TheEggsquidzidBoi 38 — 4y
Ad

Answer this question