Lesson · with Tilt

Coins and Score

Add coins the player can collect and a score on screen, using the Touched event.

You need

  • Roblox Studio
  • A mouse is strongly recommended

Steps

  1. Make a score label

    In StarterGui insert a ScreenGui, then a TextLabel. Set its Text to Score: 0.

  2. Make a coin

    Insert a small yellow Part named Coin, anchored, with CanCollide off.

  3. Script the touch

    Add a Script to the coin: local coin = script.Parent coin.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then coin:Destroy() end end)

  4. Count it

    With your instructor, connect the coin to the score using a LocalScript or leaderstats, so the label goes up by 1.

  5. Balance it

    Place 5 coins. Put the hardest coin somewhere risky. Is it worth the risk?

Build task

One mechanic

Add ONE mechanic that makes your game yours: collect, avoid, race or build.

Finish line: Coins disappear when touched and your score changes.

Check your understanding

1. Which event runs when something bumps into a part?
2. Why check GetPlayerFromCharacter before destroying the coin?
Guest mode: your result is saved on this device only.