I want to display text, but I only get errors

Godot Version

<v4.1.1>

Whats up? I have a problem. I have a ressource called Tage filled with other ressources. The interesting one is Beschwerden. Beschwerden is filled with 2 texts that are interesting for this problem. First one is called label_Text, second one is calles beschwerde_Brief.

If you open a boxcontainer, my code looks into the beschwerden resource for that Tag (german for day, if you didn’t know) and creates for every beschwerde an instance of a texturebutton + label I made in another scene. The label gets label_Text of t as text. Then it is add the a Boxcontainer and last but not least it emits a singal.

Code 1:
extends Control

signal this_are_the_buttons()

var tag
var box

func _ready():
	tag = load("res://Script/Tage/Test_Tag.tres") as Tage
	box = get_node("/root/Control/Anfragen_Liste/Raster")


func _on_visibility_changed():
	var anfragen_Label_standard = load("res://Anfragen_Label.tscn")
	
	for t in tag.beschwerden:
		var anfragen_Label_instanz = anfragen_Label_standard.instantiate()
		anfragen_Label_instanz.find_child("Label").text = t.label_Text
		box.add_child(anfragen_Label_instanz)
		this_are_the_buttons.emit()

In the code of the texturebutton + Label itself i supposed to open a chart that displays the beschwerde_Brief. But now the messy part beginns.

extends Control

var text_Label
var anfragen_Liste
var anfragefeld
var anfragen_raster
var tag 
var zähler

func _ready():
	text_Label = $Chart/Brief
	anfragefeld = $"."
	anfragen_Liste = get_node("/root/Control/Anfragen_Liste")
	anfragen_raster = $"../Anfragen_Liste/Raster"
	tag = load("res://Script/Tage/Test_Tag.tres") as Tage
	zähler = -1

So far so good. The next one is the back button also self explainatory. I hope.

func _on_zurück_anfragenfeld_pressed():
	anfragefeld.hide()
	anfragen_Liste.show()
	zähler = -1

Now, when the signal from the first code hits, I collect all the children of the boxcontainer in an array and for i in array, I firstly one up the zähler (which is counter in german) and connect i when pressed with _on_open and zähler.

func _on_anfragen_liste_this_are_the_buttons():
	var alle_Kinder: Array = anfragen_raster.get_children()
	for i in alle_Kinder:
		zähler += 1
		i.pressed.connect(_on_open.bind(zähler))

Lastly I tried to display the right beschwerde_Brief to the chart. So I made an array and for every beschwerden a day I add the beschwerde_Brief of the beschwerde to the array. Then I use the zähler to get the right beschwerde_Brief and make it the text of the chart.

func _on_open(nachricht):
	var array = []
	for t in tag.beschwerden:
		var m = t.beschwerde_Brief
		array.append(m)
	text_Label.text = array[nachricht]

And nothing works. I see no text and I get different Errors almost random. I know it’s a fucking mess, but I have no idea how to do it easier or solve my problem.

Hi!
I didn’t get your problem, I think. But let’s try.
In Code 1, _on_visibility_changed you load the template scene every time. Do you delete it anywhere? The next functions only use hide() (in _on_zurück_anfragenfeld_pressed). So, run your project, look at the left side of the editor and switch to “remote”. There you can see what is created in a live environment. Often helps to see such things, like having 10 instances of something. If it is intentional to not delete those instances, nevermind.
Perhaps it would help to explain the goal. And of course most important: write down the error messages, so that we know what errors you get.
I guess you try to create a kind of message box to sort or filter complaints?