Last active
December 2, 2021 00:30
-
-
Save lucasmz-dev/65d3d3355803d351f6b78ce4094427d9 to your computer and use it in GitHub Desktop.
Exit implementation in Luau (task. required)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[=[ | |
A function which makes it so that the current thread is interrupted, and causes an error when on an attempt to resume it. | |
@yields | |
]=] | |
local function exit() | |
task.defer( | |
coroutine.close, | |
coroutine.running() | |
) | |
coroutine.yield() | |
error("Attempted to resume dead coroutine") | |
end | |
return exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment