PPristone AcademyLearn · Mentor · Build
The Roblox Builder's Quest · Systems · Mission 4 · +150 XP · ⏱ 35 min

The treasure — coins and a real score.

Two scripts, two places, one system. This is how real games are wired together.

Win condition

Touch a coin → it vanishes → your score goes up on the actual leaderboard in the corner of the screen.

200,000 FT
The Big PictureYour first two-script system

One script builds the scoreboard. Another pays into it.

Until now, one script did one job. Real games are systems — separate scripts in separate places that depend on each other. Today's pair: a scoreboard builder that runs when a player joins, and a coin that finds that scoreboard and adds to it.

30,000 FT
The BuildScript 1: the scoreboard

Script 1 — the scoreboard (ServerScriptService).

1

In Explorer: ServerScriptService → + → Script. Name it Leaderboard.

2

Type:

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Value = 0
    coins.Parent = leaderstats
end)
The magic name

Roblox has a built-in rule: any folder named exactly leaderstats — lowercase, no spaces — inside a player automatically shows on the leaderboard. Spell it exactly or nothing appears.

30,000 FT
The BuildScript 2: the coin

Script 2 — the coin (inside a Part).

3

Insert a new Part. Properties: BrickColor Bright yellow, Material Neon, and check Anchored so it doesn't fall.

4

Name it Coin and add a Script inside it:

local coin = script.Parent
local reward = 10
local collected = false

coin.Touched:Connect(function(hit)
    if collected then return end

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        collected = true

        local leaderstats = player:FindFirstChild("leaderstats")
        if leaderstats then
            local coins = leaderstats:FindFirstChild("Coins")
            if coins then
                coins.Value = coins.Value + reward
            end
        end

        coin:Destroy()
    end
end)
5

Play. Touch the coin. Watch the top-right: Coins: 10.

UNDER THE HOOD · NEW TOOLS
The UnderstandingFour unlocks

The tools you just unlocked.

Instance.new(...)

Creates objects from code instead of clicking. Folder, IntValue, even Parts — you can build anything this way, while the game runs.

GetPlayerFromCharacter

Stricter than the Humanoid check: it only says yes for actual players, never NPCs. Coins should pay people, not zombies.

coin:Destroy()

Deletes the coin from the game. Gone. That's also a debounce — a destroyed coin can't be touched twice (the `collected` flag covers the tiny window before it vanishes).

The checking chain

Find leaderstats, then find Coins, then add. Each step confirms the thing exists before using it. This habit is the whole difference between working code and crashing code.

The two scripts are a bank and an ATM. The bank (Leaderboard script) opens an account for every customer who walks in. The ATM (coin) never creates accounts — it looks yours up and deposits into it.
Side quest · +25 bonus XP

Duplicate the coin (Ctrl+D) five times and scatter them. Make one worth 50 by changing `reward` — and make that one bigger and a different color so players can tell it's special.

0 FT · WHEELS DOWN
Repair Shop + DebriefIf it didn't work

The Repair Shop.

🔧 The leaderboard doesn't show up

The folder must be named exactly leaderstats — all lowercase, no spaces. It's a magic name.

The Leaderboard script must be in ServerScriptService, not inside a part.

Were you already in Play mode when you added it? PlayerAdded only fires when a player joins — Stop and press Play again.

🔧 The coin falls through the floor or flies away

Check Anchored in the coin's Properties.

🔧 The coin vanishes but the score doesn't change

Check both spellings match across the two scripts: leaderstats and Coins. FindFirstChild searches by exact name.

Scripts cooperate by location and name

Script 1 builds a thing in a known place with a known name; Script 2 finds it by that name. That's system design, miniature edition.

Check the chain, every link

leaderstats, then Coins, then add. Nil-checks at every step — the crash-proof habit.

Mission complete

+150 XP. You have an economy. Mission 5 adds physics.

THE TREASURE · THE ROBLOX BUILDER'S QUEST · MISSION 4
Two scripts, two places · leaderstats is a magic name · Instance.new builds from code · Destroy() is permanent.
Next: the launch pad — a pad that sends players flying.