Build a Simple Collectible System in Roblox Studio with AI Assistance

This small Roblox example gives a player one point for touching an available coin. It hides the coin for three seconds, then brings it back. Everyone shares the same coin, and scores last only for the current server session.

Use a new disposable Roblox Studio place and allow 60–90 minutes. You need Studio and permission to edit the place. No paid assets or publication are required. The script below is a reviewable starting point; test it in Studio before using it in a real experience.

Roblox coin setup with a server Script and the four expected pickup checks.
Expected setup and checks for the supplied Roblox prototype; not a Studio screenshot or a claimed test run.
Read this example as text

Object setup

  • Workspace → Coin
  • Anchored Part
  • CanCollide: false
  • Server Script inside Coin

Checks in Studio

  • Player touch → one point
  • Extra touches → no repeat reward
  • Wait three seconds → available
  • Non-player touch → no points

See the finished example

Open the complete example

Read the complete finished example

Studio has not been run here, so no finished Studio screenshot or verified Roblox outcome is claimed.

Exact object setup and tests

What the script does

One shared coin awards a player one point, hides for three seconds, then returns. The score is a player attribute. There is no gate, permanent save or leaderboard display in this increment.

local Players = game:GetService("Players")
local coin = script.Parent
local cooldown = 3
local available = true
local originalTransparency = coin.Transparency

coin.Touched:Connect(function(hit)
    if not available then return end
    local character = hit:FindFirstAncestorOfClass("Model")
    local player = character and Players:GetPlayerFromCharacter(character)
    if not player then return end

    available = false
    local score = player:GetAttribute("TutorialCoins") or 0
    player:SetAttribute("TutorialCoins", score + 1)
    print(player.Name, "coins:", score + 1)
    coin.Transparency = 1
    coin.CanTouch = false

    task.delay(cooldown, function()
        if not coin.Parent then return end
        coin.Transparency = originalTransparency
        available = true
        coin.CanTouch = true
    end)
end)

Try the rule model

The preceding design tutorial has a working browser model. It helps explain shared cooldowns, but does not establish that this Luau script works in Studio.

Studio test results are still marked NOT RUN.

The source and setup are complete, but a genuine Studio result still requires running the script in Roblox Studio. No Studio screenshot or successful run is claimed.

1. Create a clear object hierarchy

Add an anchored Part to Workspace and name it Coin. Make it visible, set CanCollide to false and keep CanTouch enabled. Put a normal server Script inside Coin. Do not put this code in a LocalScript.

The script uses script.Parent as the pickup. Its server context matters because the server controls rewards. Roblox describes script contexts and diagnostics in its scripting documentation.

2. Give the AI the exact setup

Review a Roblox coin prototype. Workspace contains an anchored BasePart
named Coin with a server Script inside it. Touching an available coin
should award one point, hide it for three seconds, then restore it.
The coin cooldown is shared across players. Ignore non-player touches.
Scores last only for the current session. Explain script placement,
duplicate-touch handling and a two-player test. Do not add DataStores,
RemoteEvents, paid assets or publishing steps.

3. Read and insert the prototype

local Players = game:GetService("Players")
local coin = script.Parent
local cooldown = 3
local available = true
local originalTransparency = coin.Transparency

coin.Touched:Connect(function(hit)
    if not available then return end
    local character = hit:FindFirstAncestorOfClass("Model")
    local player = character and Players:GetPlayerFromCharacter(character)
    if not player then return end

    available = false
    local score = player:GetAttribute("TutorialCoins") or 0
    player:SetAttribute("TutorialCoins", score + 1)
    print(player.Name, "coins:", score + 1)
    coin.Transparency = 1
    coin.CanTouch = false

    task.delay(cooldown, function()
        if not coin.Parent then return end
        coin.Transparency = originalTransparency
        available = true
        coin.CanTouch = true
    end)
end)

This uses a player attribute rather than a leaderboard display. Inspect the attribute or Output to see the score. It assumes this tutorial owns TutorialCoins and stores a number there. A production project should validate shared data assumptions.

4. Understand the event guard

The script checks availability and identifies a player before rewarding. It sets availability false before updating the score. That prevents subsequent touch callbacks from awarding again during the same cooldown.

Roblox touch events can repeat; a cooldown guard addresses that explicitly. Debounce patterns The hidden part still exists in Workspace, which is why both its visibility and touch behaviour are managed.

5. Test before extending

Run a one-player test. Touch the coin, inspect Output and keep moving through its location. Confirm one reward during three seconds, then another after respawn. Use a two-player Studio test and confirm the pickup is shared: the second player cannot claim it during the same cooldown.

Try a non-player collision and check it gives no points. Reset the session and confirm scores reset. If you need a persistent inventory, private per-player coins or exploit resistance beyond this small server prototype, design and test those as separate features.

Nothing runs: verify server Script placement and inspect Output. No visible score: attributes do not create a leaderboard automatically. Multiple rewards: inspect duplicate script instances and whether the guard was changed.

The code has not been executed in Studio as part of this draft. Record the Studio version and actual test results before describing a finished implementation as tested.

Scroll to Top