Luau

Luau is the scripting language used in Roblox Studio. It is a fast, small, safe, gradually typed embeddable scripting language derived from Lua 5.1. Use Luau in scripts to make your experience dynamic and interactive. For a comparison of language features in Luau and C#, see Luau and C# Comparison.

Support in Studio

The Script Editor in Studio supports Luau with autocompletion, syntax highlighting, static linting, type checking, and script analysis. It also shows documentation and function signatures for members of the Roblox Engine API.

Types

Luau includes the following data types:

  • nil represents non-existence or nothingness. It's different from any other value or data type.
  • Booleans, or bool, have a value of either false or true.
  • Numbers, or double, represents double-precision (64-bit) floating-point numbers.
  • Strings are sequences of characters, such as letters, numbers, and symbols.
  • Tables are arrays or dictionaries of any value except nil.
  • Enums are fixed lists of items.

Luau is dynamically typed by default. Variables, function parameters, and return values can be any data type. This helps you write code faster because you don't need to provide types for each piece of data. You can still declare explicit types for variables in Luau and enable strict type checking to make type issues obvious and easy to locate.

Data Structures

You can also implement the following data structures using primitive data types:

  • Stacks are Last-In-First-Out collections of items that you can implement using tables.

  • Metatables are tables with advanced configurations that can achieve functionalities such as storing pairs of keys and values and calculating arithmetic operations.

Features

In Luau, variables and functions can have global and local scope within a script. Luau has logical, relational, and compound assignment operators. You can use control structures and functions to control when Luau executes code. Many operators and variable assignments perform type coercion to change values to the types that Luau expects.