struct / class
Declare the type in a .clh. Implement Class::Method in the sibling .clp / .clpp.
Syntax
Section titled “Syntax”struct LeaderstatsServer { Janitor janitor; void OnPlayer(Player player);};Parameters
Section titled “Parameters”None.
Return value
Section titled “Return value”A type (and, for field-only headers, a constructor function).
Luau emit
Section titled “Luau emit”export type + function Class:Method / const function Name() for field-only
Description
Section titled “Description”class is a synonym of struct. public: / private: / protected: are ignored.
Field-only structs in a header emit const function Name() with defaults (DataStore templates). Nested structs with defaults become nested tables.
Stems must match: LeaderstatsServer.clh beside LeaderstatsServer.server.clpp.
Instances are not RAII. Leaving a block does not Destroy — use Janitor.
Example
Section titled “Example”struct LeaderstatsServer { Janitor janitor;};Emits:
-- export type LeaderstatsServer = { janitor: Janitor, ... }See also
Section titled “See also”class-method · this · init · access-labels