How to stop a function while its running?? I'm looking how to stop it from outside the function. Using return
or break
will stop from within the function, which is not what I'm really looking for.
Any help would be appreciated. Thanks in Advance!!
setfenv(func,{})
What you can probably do if its a while true loop or some other loop is check if a value you defined earlier is false or true
For example:
local Check = false coroutine.wrap(function() while Check == false do print("Running") wait(0.1) end end)() wait(5) Check = true -- This will make the function stop running
You could also use the same logic for a function you have defined:
local Check = false function GoodFunction() coroutine.wrap(function() if Check == false then repeat print("Good") wait(0.1) until Check == true end end)() end GoodFunction() wait(5) Check = true
Let me know if you have any issues!