Module 2 · Values and variables
Strings store text
Use matching quotes, empty strings, and numeric-looking text deliberately.
What you will learn
- Create string variables with matching quotes
- Explain what an empty string represents
- Distinguish text digits from a number
- string
- A sequence of characters used as text.
- empty string
- A string containing zero characters, written as two matching quotes.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Coin Quest uses text for player-facing names, item labels, and status messages. Treating that text consistently prevents confusing type errors later.
The mental model
Quotes mark the beginning and end of string data. The quote characters are syntax; they are not normally part of the stored text.
An empty string is still a present string value. It differs from nil, which says no value exists.
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 questName = "Coin Quest"local currentHint = ""local doorCode = "2048"print(questName, currentHint, doorCode)Line by line
- 3
Matching double quotes store the game title.
- 4
Two adjacent quotes create a present but empty string.
- 5
2048 is text here because it is quoted.
- 7
The three string values are printed as 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: Matching double quotes store the game title.
Line 4: Two adjacent quotes create a present but empty string.
Line 5: 2048 is text here because it is quoted.
Line 7: The three string values are printed as 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: All three variables remain strings and the formerly empty hint becomes visible.
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 value is text even though it contains only digits?
Try it
Mark each step after you have tried it.
Common mistake
local questName = "Coin Quest'The opening and closing quote styles do not match, so Luau cannot tell where the string ends. Use a matching pair.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Strings store text between matching quotes.
- An empty string is not nil.
- Quoted digits remain text.
Next: Next, you will store numbers and calculate with them.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.