# Can't add child '…' to '…', already has a parent '…' in Godot 4

A node has one parent, and this one already has it. b.add_child(c) after a.add_child(c) prints Can't add child 'Coin' to 'Shelf', already has a parent 'Bag'. and leaves it where it was. Move it with c.reparent(b), or remove it from its parent first.

Source: https://flockbay.com/godot/cant-add-child-already-has-a-parent/ · Updated 2026-10-30

## What Godot is checking

Node::add_child() refuses a node whose parent is set, prints this error with the three names, and returns. The script carries on, and the node stays under its first parent.

reparent() removes the node from its parent and adds it to the new one in one call, and by default keeps its global transform.

## Reproduce it

A coin added to a bag, then added to a shelf.

```
extends Node

func _ready() -> void:
	var bag := Node.new()
	bag.name = "Bag"
	var shelf := Node.new()
	shelf.name = "Shelf"
	add_child(bag)
	add_child(shelf)
	var coin := Node.new()
	coin.name = "Coin"
	bag.add_child(coin)
	shelf.add_child(coin)
	print("coin is under ", coin.get_parent().name)

```

## What Godot 4.7.2 prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

ERROR: Can't add child 'Coin' to 'Shelf', already has a parent 'Bag'.
   at: add_child (scene/main/node.cpp:1717)
   GDScript backtrace (most recent call first):
       [0] _ready (res://answers/cant-add-child-already-has-a-parent/repro.gd:13)
coin is under Bag
```

## Fix it

Move it with reparent().

```
extends Node

func _ready() -> void:
	var bag := Node.new()
	bag.name = "Bag"
	var shelf := Node.new()
	shelf.name = "Shelf"
	add_child(bag)
	add_child(shelf)
	var coin := Node.new()
	coin.name = "Coin"
	bag.add_child(coin)
	coin.reparent(shelf)
	print("coin is under ", coin.get_parent().name)

```

## What the fixed script prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

coin is under Shelf
```

## Run this fix with your agent

Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.

```
My Godot 4 project prints this error: "Can't add child 'Coin' to 'Shelf', already has a parent 'Bag'.". Find where it comes from and fix it. A node has one parent, and this one already has it. b.add_child(c) after a.add_child(c) prints Can't add child 'Coin' to 'Shelf', already has a parent 'Bag'. and leaves it where it was. Move it with c.reparent(b), or remove it from its parent first. Then run the game headless and check that Godot's output no longer shows it.
```

## Adding the same instance twice in a loop

Instantiating once outside a loop and calling add_child() inside it adds the first copy and refuses the rest. Call instantiate() inside the loop so each pass makes a new node.

```
for i in 5:
	var enemy := enemy_scene.instantiate()
	add_child(enemy)

```

## Verified on Godot 4.7.2

Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.

Where the check lives in Godot's source: [node.cpp line 1717, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/scene/main/node.cpp#L1717), [Node.reparent in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Node.xml).

## Questions

### What does remove_child() do to the node?

It takes it out of the tree without freeing it. Add it somewhere else, or free it, or it leaks.

### Does reparent() keep the position?

Yes, by default it keeps the global transform. Pass false as the second argument to keep the local one.

Download Flockbay free: Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot. https://flockbay.com/download/

Related: [Parent node is busy setting up children, `add_child()` failed in Godot 4](/godot/parent-node-is-busy-setting-up-children/), [Node not found: "…" (relative to "…") in Godot 4](/godot/node-not-found-relative-to/), [Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead in Godot 4](/godot/cant-change-this-state-while-flushing-queries/), [Attempted to free a RefCounted object in Godot 4](/godot/attempted-to-free-a-refcounted-object/), [Every verified Godot 4 answer](/godot/), [How do I see Godot’s output and errors in Flockbay?](/docs/how-do-i-see-godots-output-in-flockbay/)
