Module 12 · Modules, persistence, and the capstone
Capstone: Coin Quest
Assemble server-owned coins, validation, responsive HUD, modules, cleanup, and optional persistence into a playable prototype.
What you will learn
- Assemble the reviewed Coin Quest file layout
- Run selected public behavior cases
- Explain what remains optional or manually observed
- capstone
- A final project combining the course's major ideas.
- vertical slice
- A small end-to-end feature crossing the necessary system layers.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
The capstone turns each isolated lesson into one playable path: a player enters, collects a validated coin, sees a responsive count, reaches a checkpoint, and can extend persistence later.
The mental model
Shared modules define safe configuration. A bootstrap initializes and starts server services. The server owns coin state and sends approved updates. The client HUD presents those updates and cleans its connections.
The Studio Companion checks only marked capstone targets and public cases. Persistence remains an optional extension because production saving requires more architecture than this prototype.
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.
local is read as “local”: it creates a name that is available only in the current code scope.
{ } is read as “opening and closing braces”: it creates a table value around its entries.
: is read as “colon”: it calls a method with the object supplied as the first receiver value.
= is read as “is assigned”: it evaluates the right side and stores that value in the name on the left.
. is read as “dot”: it accesses a named property or table field.
A tiny example
--!strictlocal ServerScriptService = game:GetService("ServerScriptService")local ReplicatedStorage = game:GetService("ReplicatedStorage")local CoinService = require(ServerScriptService.LearningLuau.Services.CoinService)local CoinConfig = require(ReplicatedStorage.LearningLuau.Shared.CoinConfig)CoinService.Init({ coinValue = CoinConfig.coinValue, maxDistance = CoinConfig.maxDistance, feedbackRemote = ReplicatedStorage.LearningLuau.Remotes.CoinFeedback,})CoinService.Start()Line by line
- 3
The bootstrap requests the two containers it coordinates.
- 6
The authoritative service stays server-only.
- 7
Safe immutable configuration is shared.
- 9
Init receives explicit dependencies.
- 12
The feedback RemoteEvent is injected from a fixed path.
- 14
Start begins behavior only after configuration is complete.
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 bootstrap requests the two containers it coordinates.
Line 6: The authoritative service stays server-only.
Line 7: Safe immutable configuration is shared.
Line 9: Init receives explicit dependencies.
Line 12: The feedback RemoteEvent is injected from a fixed path.
Line 14: Start begins behavior only after configuration is complete.
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: The prototype completes one validated collection path, updates local UI, and keeps unrelated place work untouched.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Shared immutable configuration
--!strictlocal CoinConfig = { coinValue = 1, maxDistance = 12,}return table.freeze(CoinConfig)Client HUD controller
--!strictlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local feedback = ReplicatedStorage.LearningLuau.Remotes.CoinFeedbackassert(feedback:IsA("RemoteEvent"), "CoinFeedback missing")local label = script.Parent.CoinCountassert(label:IsA("TextLabel"), "CoinCount missing")local connection = feedback.OnClientEvent:Connect(function(count: number) label.Text = `Coins: {count}`end)script.Destroying:Connect(function() connection:Disconnect()end)Predict before running
Which component may change authoritative coin state?
Try it
Mark each step after you have tried it.
Common mistake
Do not enable optional saving until its lifecycle, retries, migrations, and failure UI are designed. A playable in-session prototype is more honest than unsafe persistence.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Explicit modules and lifecycle keep the prototype understandable.
- The server validates and owns consequential state.
- The client presents approved feedback and cleans up resources.
Next: You now have a playable foundation for extending Coin Quest one carefully tested system at a time.
Studio challenge
Coin Quest
Checks are formative feedback, not cheat-proof certification. You can finish this lesson without the plugin.
- Target
- ServerScriptService/LearningLuau/CoinQuestServer
- Check mode
- source and output
Challenge state: idle
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.