static_cast
Source-level type annotation. Luau has no runtime casts — this does not check ClassName.
Syntax
Section titled “Syntax”T static_cast<T>(value);Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
T | type | Target type, often Folder / Player. |
value | any | Expression to re-annotate. |
Return value
Section titled “Return value”value unchanged, annotated as T.
Luau emit
Section titled “Luau emit”value (with a Luau type annotation)
Description
Section titled “Description”const_cast, reinterpret_cast, and dynamic_cast also emit the argument. (void)x; is dropped (silences unused in clangd).
To branch on Instance class at runtime, use match (IsA).
Example
Section titled “Example”Folder folder = static_cast<Folder>(existingFolder);Emits:
local folder: Folder = existingFolder