Im currently trying to use signals for a sword attack for my first Godot project, but while trying to connect the sword’s custom signal to the enemy’s function, I’ve gotten “slime.gd:8 @ _ready(): Node not found: “res://scenes/sword.tscn” (relative to “/root/Game/Slime”).” "I’ve tried looking at other posts on the forum and looking at tutorials and nothing’s helped.
The code im using to reference the variable is:
@onready var sword = get_node("res://scenes/sword.tscn")
I can provide additional pictures if need. Thanks in advance!
“res://scenes/sword.tscn” is a file on your filesystem, it’s not a node.
Can you post a screenshot of your scene tree ? the Slime (?) or Game scene ? so we can help you determine the correct path for the node
You reference a filepath but without adding it to the scene tree it doesn’t exist. If you want to add it here (probably not), you have to instantiate it and add it as a child of a node in the scene tree.
If you add it somewhere else (e.g. in a player scene or inventory) you have to reference the path to the node, not the path to the scene.
If you need the sword in the slime script, I would suggest an @export variable instead of a @onready
That way you can simply assign it from the inspector dock directly
@onready var sword = get_node("res://scenes/sword.tscn")
becomes
@export var sword
But if you only need a Signal from the sword you dont even need to declare a variable. You can connect the signal directly from the signals tab (like it seems you’ve done for the Coin node)