Skip to content

auto

Type

Infer the type from the initializer. Prefer explicit types on parameters and struct fields.

auto players = GetService<Players>();
auto janitor = new Janitor();
auto [ok, result] = pcall(fn);

None.

Whatever the initializer produces.

local name = … (Luau annotation when known)

Inferred for new Class(...), GetService<T>(), datatype constructors, and destructuring.

Do not use auto as a replacement for a public API type.

auto coins = new IntValue(leaderstats);

Emits:

local coins: IntValue = Instance.new("IntValue")
coins.Parent = leaderstats

new · GetService · destructure