Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.
Keep reward amounts on the server
v2 · Activity 1 of 0 · server-state · authority · 28 min Requires Roblox Studio
Chapter outline
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.
Your task
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 |
|---|
Syntax in this activity
New syntax: server-state, authority
Earlier ideas used here
- remoteevent
- communication
- client-server
- replication
- authority
Self-check rubric
- Only server code grants the fixed amount.
- Duplicate initialize calls for the same Player do not increase it.
- Leaving removes the temporary record.
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.
Build this hierarchy
ServerScriptService WelcomeReward (Script, RunContext=Server)
- Use an isolated Baseplate practice place.
- Inspect Player attributes in the server view during a two-client test.
ServerScriptService/WelcomeReward.server.luau
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) endExpected output
- Each server Player has PracticeCoins=10.
- A rejoin creates a new temporary record; this lab is intentionally not persistent.
Studio assessment checklist
Multiplayer tests
- Two players receive independent temporary records.
- A client-only coin attribute change does not change the server record.
Troubleshooting and production considerations
PlayerAdded 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.
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.
Reset starter
Replace this code with the starter? Download your draft to keep a copy.
Code
Studio source fileEdit 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.