Well, the title says it all. How to stop a function while its running??
Simple question, but is very vague, I know. Any help would be appreciated.
Well, the title says it all. How to stop a function while its running??
Simple question, but is very vague, I know. Any help would be appreciated.
Break ~~ stops function dead on its tracks
Return ~~ stops function dead on its tracks but returns a value
https://education.roblox.com/en-us/resources/returning-values-from-functions You can read this for return
You can just use a return statement. So if you had something like this then when a == 0 the function just ends:
local function demo(a)
if a == 0 then
return
end
end
If you leave return without any values then it just returns nothing/0 but you can also return a value so you could do return 1 and if you did local b = demo(0) then b would equal 1.
Hope this helped!
Use return to break a function, this will end the function and allow you to return values to be used by other parts of your code. You can just use “break”, this will stop the loop.
getfenv(func)["wait"]=error
This discussion is preserved as it was. New answers, comments, and votes are closed.