Module 1 · Your first Luau scripts
What Luau controls in a Roblox game
Separate the objects that make up a place from the behavior that scripts give them.
What you will learn
- Distinguish a Roblox object from scripted behavior
- Name three game behaviors Luau can control
- Luau
- The programming language used by Roblox scripts.
- behavior
- What a game does in response to time, players, or other changes.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Coin Quest needs more than coins and doors placed in a map. Code decides when a coin counts, when a door opens, and what message a player sees.
The mental model
A Part is a physical object, such as a block in your map. A Script holds instructions. Placing a block does not automatically make it award a coin; a script supplies that behavior.
For this first example, the behavior is small: show one message in Studio's Output panel. This is a developer message, not text displayed to players inside the game.
In local welcomeMessage = "Coin Quest is ready", local introduces a name, welcomeMessage is that name, and = gives it the quoted text. print(welcomeMessage) reads the named text and shows it in Output. You will practice variables in Module 2.
New words and symbols
--!strict asks Studio to check your code for type mistakes. It is an instruction for the editor and produces no Output message.
Matching quotes such as "hello" surround a string: a piece of text. The quotation marks tell Luau where the text starts and ends.
print(...) calls the built-in print function. Put the values to show inside its parentheses; separate multiple values with commas. Read the result in Studio's Output panel.
local is read as “local”: it creates a name that is available only in the current code scope.
= is read as “is assigned”: it evaluates the right side and stores that value in the name on the left.
A tiny example
--!strictlocal welcomeMessage = "Coin Quest is ready"print(welcomeMessage)Line by line
- 1
The strict directive asks Studio's Luau analyzer to catch more mistakes.
- 3
A local variable gives the message a useful name.
- 5
The print function sends that value to Output.
Read the code aloud
Create a local name, welcomeMessage, and give it the text Coin Quest is ready. Then print the value called welcomeMessage.
Execution trace
Studio starts GameStart during the server test. Line 1 configures analysis and the blank lines are skipped.
Line 3 stores the text Coin Quest is ready under the name welcomeMessage.
Line 5 reads that stored text and print adds one Output entry. The script then reaches the end.
State before and after
Before: No welcome message from this test is in Output.
After: Output contains one welcome message. No coin, door, or visible in-game label has been created.
Predict before running
What will this script add to Output when the server starts?
Try it
Mark each step after you have tried it.
Common mistake
local door = workspace.DoorReading a line like this does not open the door. It only gives an existing object a local name; another instruction must change a property or call a method.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Objects make up the place you can inspect.
- Luau scripts give the game behavior.
- Output provides visible feedback from code.
Next: Next, you will locate the Studio panels used to create, inspect, and test that behavior.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.