So i have this lua code compiler for my game but i want to put it in a coroutine so i can stop loops in the code players write.
I have read into coroutines but they “wont work”, .wrap works but only one time then it errors and idk how to continue.
local compile = require(script:WaitForChild("Yueliang"))
local createExecutable = require(script:WaitForChild("FiOne"))
getfenv().script = nil
local CodeExecute = function(source, env)
print(source, env)
local executable
local env = env or getfenv(2)
local name = (env.script and env.script:GetFullName())
local ran, failureReason = pcall(function()
local compiledBytecode = compile(source, name)
executable = createExecutable(compiledBytecode, env)
end)
if ran then
return executable
end
return nil, failureReason
end
local corou = coroutine.wrap(CodeExecute)
return corou