It work one time and it won't again

Godot Version

Godot 4

Question

am following the Godot Using signals documentation, and on the 8 row it’s throwing an error.
And I don’t know why, it work the first run but not the second.

The green arrow on line 18 shows that you have already connected this function to a signal. Could it be that that connection (done via the editor) is conflicting with the same connection you are attempting on line 8? Try removing the connection in the editor.

here is a look at the error it’s throwing at me.

Node not found Timer
Timer is child of Sprite2D so

var Timer=get_node(“./Timer”)

didn’t work.

Maybe start over with a new project and scene? I copied the signals example from the docs just like you and I cannot reproduce your issue. Works fine for me with the same Godot version, 4.2.1.stable.

am very sorry to bother your guys time but still nothing.

You don’t have to apologize for anything, no one here was born knowing.

You have to make an effort to read the error messages, they may sound like Chinese to you but little by little you will decipher more of them

image
The error is located in the file Sprite2D.gd line 7

image
When _ready() has been called

image
I think this is understood without explanations

you are in the same mistake as before, trying to access timer from Sprite2D, you must use the correct relative path

His code matches the example from the docs. The relative path prefix is not required. I do not need to write node paths like that. He also tried your solution and it didn’t work, see above.

I found the problem.
The node Timer, I added to the node2d scene with the sprite2d as the parent shown in the screenshots.
what I did was get rid of the Timer node in Node2d scene and added it to the Sprite2d scene and just like that I solved it.
Screenshot 2024-02-29 151423

It looks like you have two scenes, node_2d and sprite_2d. The Timer node is added as a child of sprite_2d in the node_2d scene, but it doesn’t exist in the sprite_2d scene.

You’re probably getting the error, because you’re trying to run the sprite_2d scene on its own. Try running the node_2d scene instead or add the Timer node to the sprite_2d scene.

Edit: Oh, you solved it just before my comment

1 Like

thanks everyone here who helped me, God bless you all.

2 Likes

Yes, this is it!

1 Like

FYI, you can add the Timer as a child to the Sprite2D scene in the Node2D scene as the example in the docs suggest.

but how, with out an error happening?

Run the node_2d scene, not the sprite_2d scene.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.