StatementSyntax Base Class
All statement nodes inherit fromStatementSyntax, which provides:
SemicolonToken- Optional semicolon at the end of the statementWithSemicolonToken(token)- Creates a new statement with a different semicolon
Variable Declarations
LocalVariableDeclarationStatementSyntax
Declares local variables with optional initialization. Syntax:local name1, name2 = value1, value2
Key properties:
LocalKeyword- Thelocalkeyword tokenNames- List of variable names being declared (SeparatedSyntaxList<LocalDeclarationNameSyntax>)EqualsValues- Optional equals clause with initial values
LocalDeclarationNameSyntax
Represents a single variable name in a local declaration, with optional type annotation and attribute. Key properties:IdentifierName- The variable nameAttribute- Optional attribute like<const>or<close>TypeBinding- Optional type annotation (for Luau/typed Lua)Name- String property for the variable nameAttributeName- String property for the attribute name
Assignment Statements
AssignmentStatementSyntax
Assigns values to existing variables. Syntax:a, b = 1, 2
Key properties:
Variables- List of variables being assigned to (SeparatedSyntaxList<PrefixExpressionSyntax>)EqualsValues- The equals clause with values
CompoundAssignmentStatementSyntax
Compound assignment operators (requires syntax option enabled). Syntax:x += 1, y *= 2, etc.
Key properties:
Variable- The variable being modifiedAssignmentOperatorToken- The operator (+=,-=,*=,/=,%=,^=,..=)Expression- The value expression
Function Declarations
FunctionDeclarationStatementSyntax
Declares a named function. Syntax:function name(param1, param2) body end
Key properties:
FunctionKeyword- ThefunctionkeywordName- Function name (can beSimpleFunctionNameSyntax,MemberFunctionNameSyntax, orMethodFunctionNameSyntax)TypeParameterList- Optional generic type parameters (Luau)Parameters- Parameter listTypeBinding- Optional return type annotationBody- Function body statementsEndKeyword- Theendkeyword
LocalFunctionDeclarationStatementSyntax
Declares a local function. Syntax:local function name(params) body end
Key properties:
LocalKeyword- ThelocalkeywordFunctionKeyword- ThefunctionkeywordName- Function name (IdentifierNameSyntax)TypeParameterList- Optional generic type parametersParameters- Parameter listTypeBinding- Optional return type annotationBody- Function bodyEndKeyword- Theendkeyword
Control Flow Statements
IfStatementSyntax
Conditional execution. Syntax:if condition then body elseif condition2 then body2 else body3 end
Key properties:
IfKeyword- TheifkeywordCondition- The condition expressionThenKeyword- ThethenkeywordBody- The if-body statementsElseIfClauses- List ofelseifclausesElseClause- OptionalelseclauseEndKeyword- Theendkeyword
WhileStatementSyntax
Loop with pre-condition. Syntax:while condition do body end
Key properties:
WhileKeyword- ThewhilekeywordCondition- Loop conditionDoKeyword- ThedokeywordBody- Loop bodyEndKeyword- Theendkeyword
RepeatUntilStatementSyntax
Loop with post-condition. Syntax:repeat body until condition
Key properties:
RepeatKeyword- TherepeatkeywordBody- Loop bodyUntilKeyword- TheuntilkeywordCondition- Exit condition
NumericForStatementSyntax
Numeric for loop. Syntax:for i = start, finish, step do body end
Key properties:
ForKeyword- TheforkeywordIdentifier- Loop variableEqualsToken- The=tokenInitialValue- Start valueFinalValue- End valueStepValue- Optional step value (default 1)DoKeyword- ThedokeywordBody- Loop bodyEndKeyword- Theendkeyword
GenericForStatementSyntax
Generic for loop (iterator-based). Syntax:for var1, var2 in expr1, expr2 do body end
Key properties:
ForKeyword- TheforkeywordIdentifiers- Loop variablesInKeyword- TheinkeywordExpressions- Iterator expressionsDoKeyword- ThedokeywordBody- Loop bodyEndKeyword- Theendkeyword
DoStatementSyntax
Do-end block (creates a new scope). Syntax:do body end
Key properties:
DoKeyword- ThedokeywordBody- Block bodyEndKeyword- Theendkeyword
Jump Statements
ReturnStatementSyntax
Returns from a function. Syntax:return expr1, expr2
Key properties:
ReturnKeyword- ThereturnkeywordExpressions- List of return values
BreakStatementSyntax
Breaks out of a loop. Syntax:break
Key properties:
BreakKeyword- Thebreakkeyword
ContinueStatementSyntax
Continues to next iteration (if enabled). Syntax:continue
Key properties:
ContinueKeyword- Thecontinuekeyword
GotoStatementSyntax
Jumps to a label. Syntax:goto labelname
Key properties:
GotoKeyword- ThegotokeywordLabelName- The label identifier
GotoLabelStatementSyntax
Defines a goto label. Syntax:::labelname::
Key properties:
LeftDelimiterToken- The opening::Identifier- The label nameRightDelimiterToken- The closing::
Other Statements
ExpressionStatementSyntax
A standalone expression (typically a function call). Key properties:Expression- The expression being evaluated
EmptyStatementSyntax
A standalone semicolon. Key properties:- Only the
SemicolonToken
TypeDeclarationStatementSyntax
Type alias declaration (Luau). Syntax:type Name<T> = Type or export type Name = Type
Key properties:
ExportKeyword- OptionalexportkeywordTypeKeyword- ThetypekeywordName- The type alias nameTypeParameterList- Optional generic parametersEqualsToken- The=tokenType- The type being aliased
See Also
- Overview - Syntax node hierarchy
- Expressions - Expression node types
- Types - Type annotation nodes