Capstone, part 1: brief, rules and two yard extensions

Part 1 of the Beacon Yard capstone starts from your own m14-ship game: learn the five rules updated for ProfileStore, then build and Studio-grade two in-game extensions (a Swarm target tag and a daily coin grant).

Project lesson, about 70 minutes, 6 steps

By the end you can

  • Extend your own m14-ship Beacon Yard repository while keeping its five server-authority and ProfileStore rules intact
  • Add a second wrench target tag (Swarm) directly in CombatService and prove it with a Studio playtest
  • Add a ProfileStore-backed daily coin grant with Reconcile support and prove it on the live DataService

Before this: Integration playtests, ProfileStore: the library pros use, Monetization: products, passes, subscriptions, economy, Publishing: versions, rollback, store page

1Start from m14-ship, and the five rules that stay

Start from your own completed m14-ship repository, not an earlier milestone. Before you change a single line, open ReplicatedStorage.GameTests and make sure ServerScriptService.RunGameTests:Invoke() passes on your current build.

Roblox Studio
Studio's script editor showing the playtest module GameTests, with the coin pickup test asserting that a coin adds Config.COIN_VALUE and a test attribute shortening the coin respawn.

Select a numbered pin, or a row below, to read what it marks.

Figure 1.1.

The playtest module, GameTests. Select a pin to see which rule each check protects.

Every capstone project keeps the same five rules. They are not style preferences. Breaking one opens a cheat, splits client and server truth, or loses a player's coins.

  1. Every price, duration, health and reward number lives in src/shared/Config.luau, once. UI and tests read that constant instead of copying the number.
  2. Any new remote is named in src/server/Remotes.luau and created on the server. Clients wait for it.
  3. Coins, damage, pass ownership and purchases are decided on the server.
  4. A new saved field has a default in DataMigration.template(), is filled in for existing profiles by ProfileStore's Reconcile(), and is mutated only on the server's active session. A player whose session failed to start stays memory-only and never overwrites stored data.
  5. Developer products stay on ProcessReceipt. A game pass never replaces ProcessReceipt, and a failed save never returns PurchaseGranted.
	ROUND_SECONDS = 40,
	COOLDOWN_SECONDS = 8,
	COIN_VALUE = 5,
	COIN_RESPAWN_SECONDS = 4,
	SURVIVAL_BONUS = 10,
	DRONE_SPEED = 12,
	DRONE_DAMAGE = 15,
	DRONE_HIT_COOLDOWN = 1,
	DRONE_MAX_HEALTH = 100,
	WRENCH_DAMAGE = 34,
	WRENCH_RANGE = 14,
	STUN_SECONDS = 1.6,
	WALK_SPEED = 16,
	BOOST_SPEED = 24,
	SPEED_PRICE = 25,
	SHIELD_PRICE = 40,
	COIN_PACK_COINS = 50,
Figure 1.2

The wrench deals Config.WRENCH_DAMAGE and the drone starts with Config.DRONE_MAX_HEALTH. How many swings must hit to destroy one drone?

Answer

3. 100 minus 34 is 66, minus 34 is 32, and a third hit takes it to -2. Three hits destroy the drone. Do not retune either number to make a capstone test easier.

Under Rule 4 at m14-ship, what must happen when a player's ProfileStore session fails to start on join?

  1. Keep their fallback profile in server memory only and never overwrite their stored DataStore key
  2. Overwrite their stored profile immediately with a blank template using SetAsync
  3. Store their coins on the client until they rejoin
  4. Write the fallback profile to BeaconYard_v1
Answer

Keep their fallback profile in server memory only and never overwrite their stored DataStore key. DataService places failed loads into memoryOnly so the player can keep playing without risking overwriting a locked profile.

Open this step in lesson mode · Link to this step · This confused me

2Project 1: why a new tag misses until CombatService looks for it

At m14-ship, CombatService.luau casts a ray with Enum.RaycastFilterType.Include across two CollectionService tags: Drone and Crawler1. Anything without one of those tags is invisible to the wrench.

Both sidesRemember: CollectionService tags is coloured stickers.

	params.FilterType = Enum.RaycastFilterType.Include
	local targets = CollectionService:GetTagged(DRONE_TAG)
	for _, crawler in CollectionService:GetTagged(CRAWLER_TAG) do
		table.insert(targets, crawler)
	end
	params.FilterDescendantsInstances = targets
Figure 2.1

Adding a third enemy type called Swarm means two places in CombatService.luau have to know the tag: the include list built for workspace:Raycast, and targetTag when routing the hit. Leave either one out and every swing passes straight through or returns "miss".

Where does it break?“Coloured stickers” is a good picture of collectionservice tags. Where does it stop being true?

It breaks here. A sticker does nothing until code looks for it, and a tag on the drone's root does not tag its children.

The true model. A tag is a string stored on one instance and replicated from the server. Behaviour comes from the code that queries tags, which is why tags suit marking things for systems such as raycast filters, pads and pickups.

You tag a new enemy root part Swarm, but CombatService still builds its include list only from Drone and Crawler. What happens when a player swings the wrench at the Swarm part?

  1. The ray passes through it and returns miss, because the sticker is ignored unless code asks for it
  2. The ray hits it automatically, because every CollectionService tag is included
  3. Roblox throws a runtime error and stops the drill
  4. The ray hits it if the model has a PrimaryPart
Answer

The ray passes through it and returns miss, because the sticker is ignored unless code asks for it. An Include filter sees only the instances you place in FilterDescendantsInstances. A Swarm part stays invisible until CombatService appends CollectionService:GetTagged("Swarm") and handles the Swarm tag.

Open this step in lesson mode · Link to this step · This confused me

3Build and grade Project 1 in Studio

Before editing CombatService.luau, check your understanding of the include-list rule and health math in the browser cell below. With SWARM_MAX_HEALTH = 50 and WRENCH_DAMAGE = 34, the first hit leaves 16 and the second hit destroys the target (-18 <= 0).

Luau
local function rayHits(includeTags, partTag)
	for _, tag in includeTags do
		if tag == partTag then
			return true
		end
	end
	return false
end
 
local before = if rayHits({ "Drone", "Crawler" }, "Swarm") then "hit" else "miss"
local after = if rayHits({ "Drone", "Crawler", "Swarm" }, "Swarm") then "hit" else "miss"
local h1 = 50 - 34
local h2 = h1 - 34
print(before, after, h1, h2)
Figure 3.1. Expected output: miss hit 16 -18

Now make the real in-game change in your m14-ship checkout:

  1. In src/shared/Config.luau, add SWARM_MAX_HEALTH = 50 without altering WRENCH_DAMAGE (34) or DRONE_MAX_HEALTH (100).
  2. In src/server/CombatService.luau, add local SWARM_TAG = "Swarm", recognize it in targetTag, append CollectionService:GetTagged(SWARM_TAG) to targets inside CombatService.trySwing, and when tag == SWARM_TAG, subtract Config.WRENCH_DAMAGE from the hit part's Health attribute and destroy the ancestor Model (or part) when Health <= 0.
  3. Press Play and run game.ServerScriptService.RunGameTests:Invoke("capstone_swarm", "capstone-swarm") in the server command bar. The Course Runner uses the live CombatService. Copy the pass code from Output once the checks pass.

Level 3, Professional

Challenge

Extend src/shared/Config.luau and src/server/CombatService.luau in your m14-ship game, then run challenges/capstone_swarm.luau in Studio. Solution: challenges/solutions/capstone-yard-extensions.md.

Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("capstone_swarm", "capstone-swarm") in the server command bar. Copy the pass code from Output.

Done means

  • Config.SWARM_MAX_HEALTH is set to a positive number (50 recommended) while WRENCH_DAMAGE stays 34 and DRONE_MAX_HEALTH stays 100
  • Swinging at an untagged decoy part still returns miss
  • Swinging at a Swarm-tagged target returns hit and subtracts Config.WRENCH_DAMAGE from its Health attribute
  • A lethal swing destroys the Swarm model, and challenges/capstone_swarm.luau prints TEST PASS for all four checks

Hints

  1. In CombatService.luau, update both targetTag() and the targets list passed to params.FilterDescendantsInstances.
  2. Read the hit instance's Health attribute with targetRoot:GetAttribute("Health") and write the reduced value back before checking <= 0.
  3. Use the existing RunGameTests bindable so the test shares the running server's CombatService.

Why do you run capstone_swarm through RunGameTests instead of requiring CombatService from the command bar?

  1. The Studio command bar has its own require cache, so requiring a server module there returns a separate, unstarted copy
  2. CombatService cannot be required more than once per place
  3. CollectionService tags are hidden from the command bar
  4. BindableFunctions run faster than scripts
Answer

The Studio command bar has its own require cache, so requiring a server module there returns a separate, unstarted copy. The command bar keeps a separate require cache from ServerScriptService scripts. A BindableFunction created in init.server.luau runs inside the server script's cache and sees the live started services.

Open this step in lesson mode · Link to this step · This confused me

4Project 2: a daily coin grant on ProfileStore

From m10-memory onward, DataService.luau no longer hand-rolls UpdateAsync calls for player profiles. ProfileStore owns the session lock, autosaves, and BindToClose2. Adding a daily coin grant means adding one new field (lastDaily) to the template so Reconcile() populates it for every returning player automatically.

function DataMigration.template(): ProfileData
	return {
		coins = 0,
		speedOwned = false,
		legacyImported = false,
		onboardingStep = 0,
Figure 4.1
	session:AddUserId(player.UserId)
	session:Reconcile()
Figure 4.2

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
ProfileStore (m10-memory onward)Wally package managing one session-locked profile per player, autosaving, and filling new fields with Reconcile().Production games and every extension from m10 onward in Beacon Yard.Requires a Wally dependency and lives in its own store (BeaconYard_v2), so legacy records need a one-time import.
Hand-rolled DataStore with UpdateAsyncThe m06 to m09 implementation: manual session locks, retries and BindToClose.Learning how session locking works under the hood, or tiny tools with one key.You maintain every race condition, failed-load fallback and shutdown edge yourself.
ProfileService or DataStore2Earlier community libraries for session-locked saving.Only when maintaining an existing codebase that already uses them.Both are legacy; ProfileStore is the successor from the same author as ProfileService.

A reconciled profile has coins = 10 and lastDaily = 0. DAILY_COINS is 25 and DAILY_INTERVAL_SECONDS is 86400. What does this print when claimDaily runs at t = 1000 and again at t = 2000?

local data = { coins = 10, lastDaily = 0 }
local function claim(now)
	if data.lastDaily ~= 0 and now - data.lastDaily < 86400 then
		return 0
	end
	data.lastDaily = now
	data.coins += 25
	return 25
end
print(claim(1000), claim(2000), data.coins)
  1. 25 0 35
  2. 25 25 60
  3. 0 0 10
  4. 25 0 10
Answer

25 0 35. The first call sees lastDaily == 0, pays 25 coins, and stamps lastDaily = 1000. The second call is only 1000 seconds later, so it pays 0 and leaves coins at 35.

Open this step in lesson mode · Link to this step · This confused me

5Build and grade Project 2 in Studio

Wire the daily grant directly into your m14-ship game:

  1. In src/shared/Config.luau, add DAILY_COINS = 25 and DAILY_INTERVAL_SECONDS = 86400.

  2. In src/server/DataMigration.luau, add lastDaily: number to ProfileData and lastDaily = 0 to DataMigration.template().

  3. In src/server/DataService.luau, add DataService.claimDaily(player: Player, now: number?): number. Wait for the player's profile with waitProfile(player), use if now ~= nil then now else os.time(), return 0 inside the interval, otherwise set data.lastDaily, add Config.DAILY_COINS, call pushCoins(player) so leaderstats.Coins updates, and return Config.DAILY_COINS.

  4. Press Play and run game.ServerScriptService.RunGameTests:Invoke("capstone_daily_profile", "capstone-daily-profile") in the server command bar. The test runs two parts. First it opens a ProfileStore.Mock session, deletes lastDaily from that in-memory profile and calls Reconcile() on the same session. It does not save and reopen an older record, so it proves the template default and Reconcile() call, not a full upgrade of a stored profile. Second, it runs claimDaily against the live profile of the player in your Play session, then puts lastDaily and your coins back.

    Grade on a disposable profile. The second part changes the real profile in memory. It runs inside pcall, so your coins and lastDaily are put back even if your claimDaily throws, and the error shows up as a failed daily_claim_error check. Pressing Stop during the test restores nothing, and ProfileStore can autosave a half-finished change. Use a staging place and a throwaway account, and check leaderstats.Coins after an interrupted run.

Level 3, Professional

Challenge

Extend Config.luau, DataMigration.luau and DataService.luau in your m14-ship game, then run challenges/capstone_daily_profile.luau in Studio. Solution: challenges/solutions/capstone-yard-extensions.md.

Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("capstone_daily_profile", "capstone-daily-profile") in the server command bar. Copy the pass code from Output.

Done means

  • Config.DAILY_COINS and Config.DAILY_INTERVAL_SECONDS are positive constants in Config.luau
  • DataMigration.template().lastDaily is 0, and Reconcile() restores lastDaily = 0 on a mock profile whose lastDaily was removed in memory
  • DataService.claimDaily(player, now) pays Config.DAILY_COINS on first claim, updates leaderstats.Coins, returns 0 inside the interval, and pays again once the interval passes
  • challenges/capstone_daily_profile.luau prints TEST PASS for all six checks

Hints

  1. Do not call DataStoreService:UpdateAsync; mutating session.Data lets ProfileStore autosave and persist on EndSession.
  2. Call pushCoins(player) right after data.coins += Config.DAILY_COINS so leaderstats.Coins matches the profile.
  3. Accept an optional now parameter so the test can advance time without waiting 24 real hours.

A returning player saved their profile before you added lastDaily. What happens when they join your updated m14-ship server?

  1. session:Reconcile() copies lastDaily = 0 from DataMigration.template() without touching their existing coins or speedOwned
  2. ProfileStore wipes their profile and starts them back at 0 coins
  3. DataService.claimDaily throws a nil arithmetic error unless you run a manual database script first
  4. Their coins are copied back from BeaconYard_v1
Answer

session:Reconcile() copies lastDaily = 0 from DataMigration.template() without touching their existing coins or speedOwned. Reconcile fills in any key present in the template table that is missing from the loaded profile, leaving existing fields untouched.

Open this step in lesson mode · Link to this step · This confused me

6Recap

Retiring the analogy

You no longer need “coloured stickers”. A tag is a string stored on one instance and replicated from the server. Behaviour comes from the code that queries tags, which is why tags suit marking things for systems such as raycast filters, pads and pickups.

Recap

  1. The capstone starts from your completed m14-ship game and preserves all five rules, with Rule 4 updated for ProfileStore templates and Reconcile().
  2. Project 1 extends CombatService's raycast include list and targetTag for Swarm targets, verified live by challenges/capstone_swarm.luau.
  3. Project 2 adds lastDaily to DataMigration.template() and DataService.claimDaily(), verified against ProfileStore's Mock and live leaderstats by challenges/capstone_daily_profile.luau.

CollectionService tags is coloured stickers, until a sticker does nothing until code looks for it, and a tag on the drone's root does not tag its children.

Next Capstone, part 2: cosmetic pass trail, localization and thumb targets

Open this step in lesson mode · Link to this step · This confused me