0 votes

I am getting error can't add child . but am not sure why. the code works but it generates thousands of the same error.

# This file ModeDisplay.gd
var note= load("res://noteVew.tscn")

func _process(delta):
    genButtons()

func genButtons():
    for i in numberOfNotesInDisplay:
        modeNotes.append(note.instance())
        modeNotes[i].text = str(modText[MOD][i])
        add_child(modeNotes[i]


ERROR 0:00:02.814   add_child: Can't add child 'noteVew' to 'ModeDisplay', already has a parent 'ModeDisplay'.
  <C++ Error>   Condition "p_child->data.parent" is true.
  <C++ Source>  scene/main/node.cpp:1282 @ add_child()
  <Stack Trace> ModeDisplay.gd:153 @ genButtons()
                ModeDisplay.gd:123 @ _process()
Godot version 3.5.1
in Engine by (42 points)

1 Answer

0 votes
Best answer

I figured it out: I am creating the noteVew inside process. To fix it. I put the creation modeNotes.append(note.instance()) and addchild(modeNotes[i] under _ready.

by (42 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.