func
Function type and anonymous callback prefix. Callbacks, listeners, pcall bodies.
Syntax
Section titled “Syntax”func name = value;Parameters
Section titled “Parameters”None.
Return value
Section titled “Return value”A value of type func, emitted as (...any) -> any.
Luau emit
Section titled “Luau emit”(...any) -> any
Description
Section titled “Description”There are no C++ captures. Write func (int n) { } or assign func cb = func () {};.
Example
Section titled “Example”func onCoinsChanged = func (int newValue) { post("New value: " .: newValue);};Emits:
local onCoinsChanged: (...any) -> any = function(newValue: number) print("New value: " .. newValue)end