Comments
A comment is text that the Luau parser ignores at runtime. They are useful for documenting code, leaving reminders for future modifications, or temporarily disabling code without removing it.
Single-line Comments
In Luau, single-line comments are created with a double hyphen --
. Single-line comments extend to the end of the line.
type Point = { x: number, y: number }-- This is a single-line comment.-- It will not affect the execution of the program.local p: Point = { x = 3, y = 4 }print(p.x, p.y)
Multi-line Comments
In Luau, multi-line or block comments are created using double hyphens and double brackets --[[ ]]
. The compiler does not read any text in between. Multi-line comments are commonly used at the top of files to describe the purpose of a library or module, before functions to describe their intent, and in many other cases.
--[[ This is a multi-line comment.It will be ignored by the compilerand will not affect the execution of the program. ]]local function foo()local name = 'Jane'print(name)end
Multiple brackets can be nested inside of multi-line comment by using equal sign inside of the beginning and ending brackets, --[=[ ]=]
.
local String = 'Secret!'if String == 'Secret!' thenprint('What is your secret?')--[=[ This is how [[[ multiple brackets ]]]are nested inside of a block comment. ]=]end
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Luau on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Lua
Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.Beginner Friendly4 hours