function
Named function. Only bodies in .clp / .clpp emit. Prototypes in .clh become export type fields.
Syntax
Section titled “Syntax”ReturnType Name(T arg) { return arg;}Parameters
Section titled “Parameters”None.
Return value
Section titled “Return value”Whatever ReturnType is.
Luau emit
Section titled “Luau emit”const function Name(arg: T): ReturnType
Description
Section titled “Description”No overloading. No default arguments. No templates except GetService<T> / collections / static_cast.
async functions may await. void init() is the script entry.
Example
Section titled “Example”void CreateLeaderstats(Player player) { return;}
const int DoubleCoins(int coins) { return coins;}Emits:
const function CreateLeaderstats(player: Player) returnend
const function DoubleCoins(coins: number): number return coinsendSee also
Section titled “See also”lambda · async · init · class-method