Module 1 · Your first Luau scripts
Comments and readable names
Choose camelCase local names and write comments that explain intent rather than repeat syntax.
What you will learn
- Write a single-line comment
- Choose an intent-revealing local name
- Use camelCase consistently
- comment
- Text for readers that Luau does not execute.
- camelCase
- A naming style that begins lowercase and capitalizes later words.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Coin Quest will grow across twelve modules. Clear names help you return to a script later and understand which value or behavior it represents.
The mental model
A name should answer what a value means in the game. A comment should answer why a less-visible decision exists.
Single-line comments begin with two hyphens. Avoid narrating a clear line such as assigning 5 to coinCount.
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.
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
--!strict-- Keep the first round short for new players.local firstRoundSeconds = 30print(firstRoundSeconds)Line by line
- 3
The comment records the design intent behind the value.
- 4
firstRoundSeconds is a camelCase local name that includes meaning and unit.
- 6
The value is printed so you can verify it during a test.
Read the code aloud
Read one statement at a time: name the value being read, what the operation does, and where its result goes. Keep identifiers exactly as written so you can find them again in the code.
Pause at calls, conditions, and loops. Explain when the body runs before moving to the next statement; use the line notes above when a symbol is unfamiliar.
Execution trace
Begin at the first executable statement. Comments and blank lines do not run; a branch chooses which block runs, and a loop may revisit its body.
Line 3: The comment records the design intent behind the value.
Line 4: firstRoundSeconds is a camelCase local name that includes meaning and unit.
Line 6: The value is printed so you can verify it during a test.
State before and after
Before running, identify the starting values and any existing Studio objects this example needs. List what you expect to change.
After your practice change, check this result: A reader can infer both what the value measures and why you chose it.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Predict before running
Which name communicates the value most clearly?
Try it
Mark each step after you have tried it.
Common mistake
-- Set seconds to 30local s = 30The comment repeats the syntax while the name hides the meaning. Prefer a descriptive name and reserve the comment for the design reason.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Readable names carry game meaning.
- camelCase is a consistent local naming style.
- Useful comments explain intent.
Next: Next, you will combine these habits in the first Coin Quest mini-project.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.