Menu
Coddy logo textTech

Your First Luau Code

Part of the Introduction To Luau section of Coddy's Lua journey — lesson 3 of 73.

Time to write your first Luau code! The new ingredient on top of the Lua you know is the type annotation: a colon and a type name after the variable name.

local variableName: type = value

For example, a variable that should only ever hold text:

local message: string = "Hello, World!"

The : string part tells the type checker that message must contain string values. Try to assign a number to it later and the checker reports an error while you're still editing.

Luau also gives you a nicer way to build output: string interpolation. A string written with backticks can embed any expression inside curly braces:

local name: string = "Coddy"
print(`Hello, {name}!`)        -- Hello, Coddy!
print(`2 + 3 is {2 + 3}`)      -- 2 + 3 is 5

Compare that with chaining .. everywhere — interpolation keeps the text readable while the {braces} do the work of concatenation.

challenge icon

Challenge

Easy

Create a variable named language with an explicit type annotation of string and assign it the value "Luau".

Then print the message Hello, Luau! using string interpolation — a backtick string that embeds {language}.

Try it yourself

-- Write code here
-- 1) declare language: string = "Luau"
-- 2) print the greeting with a backtick string: `Hello, {language}!`
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction To Luau