Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.
v2 · Activity 2 of 4 · server-state · authority · 28 min Requires Roblox Studio
The server owns the practice coin record. It publishes a read-only-for-gameplay display through an attribute; clients may display their local replica, but cannot authorize a server update by editing it.
This lab awards a fixed welcome amount during server initialization, once per Player object. No client reward request exists. The next lessons add validated requests and duplicate prevention.
Initialize each player’s server record at zero, add a fixed welcome award of 10 once, and publish PracticeCoins. Guard repeated initialization of the same Player and clean the record on leave.
Interface: Complete the documented Studio hierarchy and self-check the behavior outside the browser.
| Input | Expected |
|---|
local data = { coins = 0 }
data.coins += 10
player:SetAttribute("PracticeCoins", data.coins)The published attribute reflects the server record after a server-owned transition.
New syntax: server-state, authority
Your explanation is a self-check. Exact wording is not automatically graded.
Self-checked Studio exercise. A saved checklist records your own review; no uploaded place file or screenshot is executed here.
ServerScriptService WelcomeReward (Script, RunContext=Server)
Main guided reference implementation; use the hierarchy’s stated Script or ModuleScript type.
local Players = game:GetService("Players")
local records = {}
local function initialize(player)
if records[player] then return end
local data = { coins = 0, welcomeGranted = false }
records[player] = data
if not data.welcomeGranted then
data.welcomeGranted = true
data.coins += 10
end
player:SetAttribute("PracticeCoins", data.coins)
end
Players.PlayerAdded:Connect(initialize)
Players.PlayerRemoving:Connect(function(player) records[player] = nil end)
for _, player in ipairs(Players:GetPlayers()) do initialize(player) endPlayerAdded alone can miss players already present when code starts; cover GetPlayers as well.
Do not publish the entire private record to every client; only publish the needed display field.
This is a bounded learning lab. It has not been executed in an approved Roblox Studio environment by this website.
A checked checklist records your own review, not automated project competence or a community verification.
The server owns the practice coin record. It publishes a read-only-for-gameplay display through an attribute; clients may display their local replica, but cannot authorize a server update by editing it.
This lab awards a fixed welcome amount during server initialization, once per Player object. No client reward request exists. The next lessons add validated requests and duplicate prevention.
Ownership means the server decides amount and transition. A visible attribute is not itself a secure persistent datastore, and a screenshot is not evidence of server validation.
Replace this code with the starter? Download your draft to keep a copy.
Edit and run these files in Roblox Studio. This browser has no Roblox services, physics, or replication.
Your output will appear here.
Sign in with RoCreators to save private progress across devices. Community verification is separate.