M MY Multiplayer: Wiki
Side
Kind

async.all

Shared

Runs every function in the list in its own thread, all at once, and makes the current thread wait until they have all ended.

any async.all(table tasks)

Parameters

NameTypeDescription
taskstableA list of functions. Entries that are not functions go straight into the result.

Returns

One value per list entry, in the same order: the first value each function returned, or the entry itself if it is not a function. Only works inside an async thread. Outside one, it logs an error and returns false.

Example

async.thread(function()
    local first, second = async.all({
        function()
            async.wait(300)
            return "first"
        end,
        function()
            async.wait(100)
            return "second"
        end,
    })
    outputDebugString(first .. " " .. second)
end)
NoteIf one of the functions raises an error, it becomes an error in the waiting thread, and the others' results are lost.

See also