I'm getting error about a non-existent signal even though my signal exists

Godot Version

Godot 4.7.2

Question

Hello Everyone, this is my first post on this forum, as I am at my wits’ end with this coding issue and genuinely feel insane, as in my head everything should be working exactly as it should be.

For context, I am not an expert in Godot and have been learning how to code my game through YouTube tutorials and blind hope, so there is a very high chance I have done something wrong and am just blind.

For my game, I have a system where, when you are standing in a specific area and type the word talk a text box appears. Now, to tell my text box exactly what text I want to be in that box, I have made it so that when the player is standing at the specific coordinates and types talk, a signal is emitted from the startingArea node to the dialoguePlayer node, and from here it’s connected and then tells the code to use a specific set of dialogue.

However, it just says the signal is non-existent, which it isn’t. I can autofill the signal name in the DialoguePlayer connect, and when I print the path in DialoguePlayer, it comes up as the StartingArea, as it should.

This used to work, and I don’t think I changed anything, so please help me, as this is now causing some unforeseen issues.

# -----------------------------
# What my startingArea Code kinda looks like (just scaled down)
# ------------------------------
@onready var player: CharacterBody2D = $player

signal treeTalkText

func checkForTalk() -> void:
	if player.position == Vector2(XXX, XXX):
		emit_signal('treeTalkText')
		$"./dialogueAreaOne".start()
		#print('It does not reply as trees cannot talk')


# -----------------------------
# What my dialoguePlayer Code kinda looks like (just scaled down)
# ------------------------------

@export_file("*.json") var dialogueFile

var treeTalkFile = FileAccess.open("res://scenes/dialogue/treeTalkText.json", FileAccess.READ)

var file
var dialogue = []
var currentDialogueID = 0
var dialogueActive = false

func _ready():
	$"..".connect('treeTalkText', checkForTreeText)

func start():
	if dialogueActive:
		return
	dialogueActive = true
	$NinePatchRect.visible = true
	dialogue = loadDialogue()
	currentDialogueID = -1
	emit_signal("textRemove") #for a seperate thing not related to this signal issue
	nextScript()

func loadDialogue():
	var content = JSON.parse_string(file.get_as_text())
	return content

func checkForTreeText():
	file = treeTalkFile

func _input(event):
	if !dialogueActive:
		return
	if event.is_action_pressed("enter"):
		nextScript()

func nextScript():
	currentDialogueID += 1
	if currentDialogueID >= len(dialogue):
		dialogueActive = false
		$NinePatchRect.visible = false
		emit_signal("dialogueFinished")
		return
		
	$NinePatchRect/text.text = dialogue[currentDialogueID]["text"]

I bet the relative reference here is the issue. Try using a name for the node you want to reference here. (In the Scene tab right-click it and select Access As Unique Name).
image

Then reference that in code instead. (You can drag that node into you code from the Scene tab while holding down control and it gives you a proper reference).

In general function calls and signals can be exchanged in many spots. If you have two nodes in a parent-child relation, you would make the parent call functions on its child, while the child uses signals, the parent connects to the child’s signals in order to not having to pass in a reference to itself. I’m not sure what relation your classes have here, but I would make sure to adhere to that convention if it makes sense to you.

Ahh, okay, I think I see what you’re saying. I tried something else right after I made this post, and after about an hour I got to a solution that doesn’t give me errors anymore, but still has some issues. I’m gonna keep working on them and hopefully fix what’s going wrong.

Thanks for your help :slight_smile:

The likely issue is that $".." isn’t pointing to the StartingArea node anymore. Try connecting directly with get_parent().treeTalkText.connect(checkForTreeText). Also check that the signal fires before start(), since file must be assigned before loadDialogue() runs.