I want to use spawn() without a function so, i could use return from spawn() to parent function
Here is what i want to do:
return("will prevent function foo() running")
--needs to be not ran
This would be a great feature to stop a function
--your code here
Unfortunately this won’t work given the nature of how threading in Roblox is handled.
An alternative solution is to set a flag (boolean variable) to true if you want your function to stop executing.
if stopExecutionFlag then return end --//set elsewhere
That’s bad, but thanks for telling me then.
You should also know that spawn is going to be deprecated soon, and you should switch to task.spawn() or coroutines for "parallel"ising code.