Is there a command to use that will stop a function while the function is running? I tried break but I dont think that works for functions.
return
should stop the function
Yeah, return
will stop functions and break
stops regular loops, e.g. for
/ while
loops
you use break for loops not for functions
You can destroy the script completely when its executed by typing script:destroy() at the end of the script.
The break and return statements allow us to jump out from an inner block.
You use the break statement to finish a loop. This statement breaks the inner loop (for, repeat, or while) that contains it; it cannot be used outside a loop. After the break, the program continues running from the point immediately after the broken loop.
A return statement returns occasional results from a function or simply finishes a function. There is an implicit return at the end of any function, so you do not need to use one if your function ends naturally, without returning any value.
That being said, in your case, you’ll need to use return.
More information can be found here.