← All guides
Game engines / Godot

Godot: make a collectible counter with signals

Use three collectible buttons to understand events, state, and a visible score without needing a character controller.

Beginner About 30 min practiceFree guide

First Play Studios · Edition 1 · Updated November 14, 2026

WHAT YOU’LL MAKE OR LEARN

Three buttons each award one seed exactly once, and a label stops at 3 / 3.

Before you start
  • A disposable Godot 4 scene
  • Basic familiarity with adding UI nodes and attaching a GDScript
In this guide
01

An event tells you something happened

A signal is a named event that another node can listen to. A Button emits pressed when it is activated. The receiving function decides what that event means in your game. Here it means ‘try to collect this seed,’ not ‘add a point regardless of state.’

Use buttons as temporary collectible objects. This removes movement and collision from the experiment, so a wrong counter has fewer possible causes. Once the rules work, a world pickup can trigger the same kind of decision.

02

Keep one source of truth

Make a Control root named SeedCounter. Add a VBoxContainer named Seeds with Buttons named SeedA, SeedB, and SeedC, plus a Label named Total. Place the container inside the visible window. Put a script on the root and use this GDScript sketch with those exact paths. Connect in code only; do not also wire pressed in the editor.

extends Control

var collected := 0

func _ready():
    $Seeds/Total.text = "0 / 3"
    for seed in [$Seeds/SeedA, $Seeds/SeedB, $Seeds/SeedC]:
        seed.pressed.connect(_collect.bind(seed))

func _collect(seed: Button):
    if seed.disabled:
        return
    seed.disabled = true
    collected += 1
    $Seeds/Total.text = str(collected) + " / 3"
03

Test the rule, not only the happy path

The button’s disabled state prevents a second collection, while collected owns the total. Updating the label happens after the accepted change. Avoid maintaining a second hidden count in the label text; that would create two values that might disagree.

Restarting this scene creates a fresh attempt, with a count of zero and enabled buttons. This example has no save file and no persistent inventory. Add persistence only after you can explain why repeated clicks cannot create extra seeds.

TRY IT YOURSELF

Collect three seeds in any order

  1. Build the exact node hierarchy and give the three buttons distinct visible names.
  2. Attach the sketch, run the scene, and collect SeedB first. Confirm the display becomes 1 / 3.
  3. Try activating SeedB again. Collect the other two and confirm that the total reaches three only once.
  4. Restart the scene and repeat in a different order.
  5. Write down which line prevents a duplicate award and why the label changes after the count.

Check your result.

  • Each accepted button activation adds exactly one.
  • Repeated activation never pushes the total above three.
  • A new run starts at zero with all three buttons available.
Guest progress stays in this browser. This records your own practice; it does not automatically test your project.

Common mistakes to watch for.

  • Connecting the same handler in both the editor and code can cause unexpected behavior.
  • Node names and script paths must match exactly.
  • This is an event/state exercise; it does not implement physical overlap pickups.
YOUR PROJECT. YOUR OWN CHATGPT.

Keep the conversation useful.

I’m building the Godot 4 SeedCounter exercise. My exact node tree and any error are below. Help me trace one button event through the duplicate guard, count update, and label update. Explain each change and give me a test for repeated activation. Do not add inventory saving yet.

Sources & version notes.

Godot 4 GDScript syntax. The sketch is provided for the exact listed node tree and has not been executed in the editor.

Further reading from the original documentation:

Practice times are estimates. Software-specific exercises are documentation-based unless their version note says otherwise.
MAKE IT A CONVERSATION

A question or a small win?

Tell the workshop what happened when you tried this guide. Ask for a useful next step, or share something you got working.

See discussions about this guide We’ll include the guide link in your draft. Sign in to post, then add your own question or progress before sharing.
KEEP GOING

One idea leads to another.

Godot: build a room from nodes and scenesUnity: understand components with a falling cubeUnity: prepare one pickup prefab for many placesExplore a learning path