Play Game Design · Godot Basics · 6 of 10

Signals

How nodes talk to each other. Instead of constantly asking “did something happen yet?”, a node can announce it. You'll make your coins announce when they're collected and show a live score.

⏱ About 25 minutes✅ Needs Basics 5
0 of 4 complete
1

Feel it: asking vs. announcing

Two identical levels keep score in different ways. Click the coins to collect them and watch the counters.

Mission
    2

    Name it

    Signals are how Godot nodes say “something just happened.”

    Signal

    An announcement

    A node emits a signal when something happens: a Timer runs out (timeout), a body enters an Area2D (body_entered), a button is pressed (pressed).

    Connect

    Choosing who listens

    You connect a signal to a function (method) on any node. When the signal fires, that function runs. One signal can connect to many functions.

    Signals tab

    Connecting without code

    Next to the Inspector there's a Signals tab listing every signal the selected node can emit. Double-click one to connect it.

    signal · emit()

    Your own signals

    Write signal collected at the top of a script, then collected.emit() whenever it happens. Now anyone can listen to your coin.

    Why it matters: the coin doesn't need to know the score exists, and the score doesn't need to check every coin. Each node does its own job, and signals connect them. That's how big games stay organized.
    3

    Prove it: wire up the level

    Connect signals (⚡) to methods (→) so the level behaves as described. Then test it.

    👇 Click a ⚡ signal on the left, then click the → method it should run on the right.

    Signals (announcements)

    Methods (things that can happen)

    Test it
    Results appear here.
    Goals
      4

      Build it in Godot: coins that announce, and a score

      About 15 minutes. Keep working in your project from Basics 5.

      Part A: the coin listens for the player

      1. Open the coin scene. Click the coin tab, or double-click coin.tscn in the FileSystem dock. Click 2D at the top if you're in the Script view. In the Scene dock, click Coin (the root, blue icon).
      2. Open the Signals tab. On the right side of the editor, next to the Inspector tab, click Signals. You'll see a list of signals grouped by type. Look under Area2D.
      3. Connect body_entered. Double-click body_entered(body: Node2D). A window called Connect a Signal to a Method opens. Coin is already selected as the receiver, and the Receiver Method box says _on_body_entered. Click Connect.Godot jumps to the script and adds a new function, _on_body_entered, with a small green icon next to it. That icon means “a signal is connected here.” 💾 Save: Ctrl+S
      4. Update the coin script. Check that coin.gd is the highlighted script in the list on the left of the Script view (the first line says extends Area2D). If not, click coin.gd in that list. Then select all and replace with this. It adds a signal of its own, removes the Basics 5 overlap check, and fills in the new function:
        Keep the function name exactly _on_body_entered, since that's what the connection points to. if body is CharacterBody2D means only the player counts, so walls touching a coin no longer collect it.
      5. Save with Ctrl+S.

      Part B: a score that listens to the coins

      1. Add a label. Click 2D, then the main tab. Select the root (Node2D, at the top of the Scene dock) → + → Label → Create. Rename it exactly ScoreLabel. 💾 Save: Ctrl+S
      2. Set it up. Keep ScoreLabel selected in the Scene dock, then work down the Inspector on the right: ① Text: near the top, in the Label section, is a box called Text. Click it and type Coins: 0. The words appear in the viewport, small and in the top-left corner.
        ② Position: scroll down to Layout and click it to expand, then expand Transform inside it. Set Position to 20 (x) and 20 (y).
        ③ Size of the text: scroll further down to Theme Overrides and expand it, then expand Font Sizes. Tick the small checkbox next to Font Size to turn it on, then set the number to 32.
        Check: the viewport shows “Coins: 0” in large text near the top-left corner, inside the purple game-window rectangle.
        Can't find a section? Type its name (like font size) in the Filter Properties box at the top of the Inspector.
        💾 Save: Ctrl+S
      3. Give main its own script. Select the root Node2D → Attach Script. Check Inherits says Node2D and the path ends in main.gd → Create. Replace the code with:
        $ScoreLabel means “my child called ScoreLabel,” which is why the name has to match exactly.
      4. Save (Ctrl+S), then click 2D.
      5. Connect the first coin. In the Scene dock of main.tscn, click Coin. In the Signals tab, at the top there's a section for coin.gd containing collected(). Double-click it. In the window, click the root Node2D in the node list, make sure Receiver Method says _on_coin_collected, and click Connect. 💾 Save: Ctrl+S
      6. Connect the others. Do the same for Coin2 and Coin3. Godot will suggest names like _on_coin_2_collected, so change the Receiver Method to _on_coin_collected each time. All three coins should call the same function. 💾 Save: Ctrl+S
      7. Save and run. Scene → Save All Scenes, make sure the main tab is open, then F6. Collect your coins.

      💾 Save before you run. A (*) on a tab means unsaved changes, which may not show up in the game.

      🛠 Common problems
      Coins vanish but the score stays at 0

      That coin's collected signal isn't connected. Select the coin in main.tscn → Signals tab: a connected signal shows a connection line underneath it. Also check the receiver method is _on_coin_collected, exactly as in main.gd.

      Error: “Invalid assignment of property or key 'text' … on a base object of type 'null instance'”

      Godot can't find $ScoreLabel. The label must be named exactly ScoreLabel (capital S and L, no spaces) and be a direct child of the root Node2D.

      Coins don't disappear any more

      The body_entered connection is missing, or the function name changed. In coin.tscn, select Coin → Signals tab and check body_entered shows a connection to _on_body_entered. Redo step 3 if not.

      Godot made a function called _on_coin_2_collected

      You kept the suggested name. Either redo the connection with _on_coin_collected, or delete the extra function in main.gd and reconnect.

      I can't find the Signals tab

      It's in the dock on the right, beside Inspector. Make sure a node is selected in the Scene dock first. Some layouts label it Node with a Signals section inside.

      Error: “Mixed use of tabs and spaces”

      Select all the code and use Edit → Indentation → Convert Indent to Tabs.

      Checkpoint

      “Coins: 0” shows in the top-left corner. Each coin you collect disappears and the number goes up by one. Coins next to walls no longer vanish on their own.

      🎯 Your turn optional · no code given

      A special coin worth 5 points

      Make one of your coins red and worth 5 points, while the others stay gold and worth 1.

      Done when collecting the red coin adds 5 to the score, and each gold coin still adds 1.

      You'll need: an @export setting (Basics 3) and a signal that carries a value. Signals can send information along with the announcement.

      💡 Hint 1 (a nudge)

      Each coin needs its own “how much am I worth” setting that you can change per coin in the Inspector. Then the signal needs to tell main how much to add, not just “I was collected.”

      💡 Hint 2 (more help)

      In coin.gd: add @export var value := 1, change the signal to signal collected(amount), and emit it with collected.emit(value). In main.gd, give the function a parameter, func _on_coin_collected(amount), and add amount instead of 1. Then in main.tscn select Coin3: set Value to 5 and Visibility → Modulate to red.

      ✅ Solution (try it yourself first!)
      # coin.gd: the changed lines
      signal collected(amount)          # the signal now carries a number
      @export var value := 1           # how many points this coin is worth
      
      func _on_body_entered(body: Node2D) -> void:
      	if body is CharacterBody2D:
      		collected.emit(value)     # send the value along
      		queue_free()
      # main.gd: the changed function
      func _on_coin_collected(amount) -> void:
      	score += amount
      	$ScoreLabel.text = "Coins: " + str(score)

      Your existing signal connections keep working, because the function name didn't change. Red tint tip: the Modulate on Coin3 in main.tscn tints just that one coin.

      5

      Quick check

      Three questions, then you're done.

      🎉 Your nodes are talking.

      You connected built-in signals, made your own, and used them to keep score without any node checking on another every frame.

      Next · Basics 7: Spawning things
      Make coins appear while the game runs, every few seconds
      Start Basics 7 →