Part 7 mini-project: Collect-All-Coins

The book's last project builds on the Touch-to-Collect Coin. You scatter several coins, count how many a player picks up, and announce a win on the last one. It uses all of Part 7 — Instances, events, services, leaderstats — plus a Part 6 loop over many objects.

What to build

When the experience runs:

  1. Each player gets a leaderstats folder with Coins at 0 (as before).
  2. Several coins sit in the world inside one Folder.
  3. Walking into a coin adds 1 to that player's Coins and removes it.
  4. When the last coin is collected, the game prints a win message.

Files

Two scripts are in projects/collect-all-coins/:

  • player-setup.lua — a Script in ServerScriptService. Builds leaderstats and Coins for each joining player.
  • coins-manager.lua — a Script in ServerScriptService. Finds every coin, wires up each Touched event, counts pickups, fires the win.

Studio setup, step by step

  1. Open Studio with the Baseplate template.
  2. Make a Coins folder.
    • In the Explorer, right-click WorkspaceInsert ObjectFolder. Rename it Coins (F2).
  3. Add some coins.
    • Right-click the Coins folder → Insert ObjectPart.
    • For that Part set, in Properties: Anchored = true, Shape = Cylinder (optional), Size = 2, 0.4, 2, BrickColor = Bright yellow, and a Position the player can reach.
    • Duplicate it (right-click → Duplicate) a few times and spread the copies around. Each copy stays inside the Coins folder.
  4. Add the two scripts.
    • Right-click ServerScriptServiceInsert ObjectScript. Rename it PlayerSetup and paste player-setup.lua.
    • Add a second Script named CoinsManager and paste coins-manager.lua.
  5. Test it. Press Play, walk over every coin, and watch the leaderboard climb. When the last coin vanishes, the Output panel prints the win message.

How the code works

  • coins-manager.lua counts the coins with #coinsFolder:GetChildren() — the list length from Chapter 22.
  • It loops over them (Chapter 28) and connects each Touched event (Chapter 33).
  • Each handler finds the player (Chapter 33), bumps their Coins (Chapter 35), removes the coin, and adds one to a shared collected counter (Chapter 20).
  • When collected reaches total, the win message prints.

The if coin.Parent == nil then return end line is a debounce: a destroyed coin's Parent is nil, so leftover touches are skipped.

A bigger challenge (optional)

  • Per-player wins. Give each player their own count so two can race; announce the first to a set number.
  • Respawn the coins. After the win, task.wait, then Clone the coins back for a new round.

Done?

When the coins can be collected, the leaderboard counts them, and the win fires on the last one — the project, and the book, are done.

You started with words on paper and ended with a playable Roblox scene. Every Roblox tutorial from here reads like the next chapter: same language, same patterns, just more services, events, Instances. Go make something.