lloyAlloy on GitHub
async
Docs

async

Updated
async function f() ... end
local job = async do ... end
async do ... end

Returns a Future. The body runs on task.spawn under xpcall, and the Future memoizes the result. async function f(): T is Future<T>, and async function f(): Future<T> names the same thing; without a return type, a body that returns a value infers T, and one that returns nothing is Future<nil>. A body that returns two values, async function f(): (A, B), is Future<A, B>, and local a, b = await f() gives both.

async do ... end is an expression whose value is that Future, so a binding can await it later. The body's value is a return or its last line, a call too. The body runs in a function of its own, so ..., break, and continue inside it are errors. It also stands alone as a statement, wherever a do block stands: the block runs for its effects and the Future is dropped.

An async function body and an async do block are the two async contexts an await needs; alloy doc await carries the rule.

The word is also free as a name. async before function or do on the same line is the modifier; every other reading is a name, so local async = false and if async then read the Luau way.