Module 1 · Your first Luau scripts
Using print() and reading Output
Print strings and several values, then use Output as deliberate feedback.
What you will learn
- Print a quoted string
- Print multiple values in one call
- Find the source of a message in Output
- function
- Named behavior that can be called; print is a built-in example.
- argument
- A value supplied inside a function call's parentheses.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Before Coin Quest has a visible HUD, Output is the clearest place to confirm that a script reached a step and holds the value you expected.
The mental model
Calling print is like adding a labeled note to a test log. Parentheses hold the values you want the function to receive; those values are its arguments.
Text must be inside matching quotes. coins has no quotes in the call because you want its stored number, 3. Commas let one print call show several values.
The practice adds true, a boolean value meaning yes. Write true without quotes to use that value; "true" would be ordinary text.
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 coins = 3print("Coins collected:", coins)Line by line
- 3
The local variable stores the number 3.
- 4
print receives a string and a number as two separate arguments.
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 local variable stores the number 3.
Line 4: print receives a string and a number as two separate arguments.
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: One Output entry clearly displays the label, coin count, and readiness value.
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 two values will Output show?
Try it
Mark each step after you have tried it.
Common mistake
print(Coins collected)Without quotes, Luau reads the words as identifiers rather than text, and the space makes the statement invalid. Put literal text inside matching quotes.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- print sends values to Output.
- Quoted text is a string.
- Labels make diagnostic output easier to understand.
Next: Next, you will make code itself easier to understand with names and comments.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.