Error output not related to actual error

Godot Version

4.5

Question

Not sure if it’s an actual problem but I’m just looking for some insights in this situation. (I’m not a coder)

I have a scene “A” with a $Timer and a scene “A1”:
Scene “A”
-Timer
-Scene “A1”

Inside “A1” script I miss-typecast a node.
@onready var mesh : CollisionShape3D = $StaticBody3D/Mesh

Screenshot 2025-10-26 165659

But when I run it the error appears in Scene “A” script as
Cannot call method 'start' on a null value. on the line timer.start()

Screenshot 2025-10-26 165730

And here I thought there was something wrong with $Timer but in actuality it was the wrong typecast in the subscene’s script.

Do you know how to pinpoint the actual error in this situation? I’m worry if it happen again I wouldn’t know where to look.

Well yeah, when an error is “somewhere else” and we don’t know exactly where - that’s called a bug. And the process of finding out where it is - that’s called debugging :smiley:
Welcome to programming!

1 Like

@normalized
Because I’ve seen error output that indicates using the wrong type correctly, something like “you are using float instead of int in a_script.gd” so I thought it would be easy error to catch. But then again what do I know.. :sweat_smile:

That’s why we have different names for those two major categories: straightforward errors and bugs. Errors are errors that are obvious, and bugs are errors that are not obvious due to complexity of your program.

For example, if you forget to initialize a reference variable, the actual problem is at the place where that initialization is supposed to happen, however the effect of that error can show in a completely different place - where you first need to use that reference, making it seem the error is “random”. Because of this, bugs in a complex program can sometimes be difficult and time consuming to find.

In your specific case the error message means that attack_start_timer wasn’t initialized. Some other code was supposed to initialize it, but it didn’t for some reason. So you need to follow that clue and find out why it isn’t initialized as you’re expecting it to be. It requires a bit of detective work so to speak.

1 Like

That makes sense, Thanks! :+1: