Attempt to call function 'rotate_x' in base 'null instance' on a null instance.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By K29

When I load the scene directly it has no error but when I go through the title screen I get this error

eyes.rotate_x(deg_to_rad(-event.relative.y * sensitivity))

How is the eyes variable being set? Based on the error, at the time the above code is executed, that variable is null

jgodfrey | 2023-06-29 18:26

@onready var eyes = get_tree().root.find_child("Head", true, false)

K29 | 2023-06-29 18:48

Ah, so this is related to your other question. As I eluded to there, I’m not convinced you found/fixed the original issue - and this related problem implies the same…

jgodfrey | 2023-06-29 19:02

Im not sure what im doing wrong. When I copy the node path of Head it just gives me "Head".

K29 | 2023-06-29 21:02

Are you sure you don’t have another (broken) reference in some other script? Or, that you haven’t inadvertently attached your script to multiple nodes. Something’s a bit fishy here, but it’s difficult to pinpoint in a forum thread…

If the project is available somewhere online for inspection, I’d be happy to take a look…

jgodfrey | 2023-06-29 21:08

unamedproject – Google Drive

here you go

K29 | 2023-06-30 00:27

Ignore it is not used

K29 | 2023-06-30 00:41

So, it looks like your script is assigned to the top level node of the Player scene AND is assigned as an AUTOLOAD script. It’s that AUTOLOAD reference that’s breaking right now.

I assume that’s unintentional and should be removed and/or disabled. That’ll fix your immediate problem, but there will be others…

jgodfrey | 2023-06-30 01:35

Thanks it worked

K29 | 2023-06-30 02:20

:bust_in_silhouette: Reply From: jgodfrey

So, as mentioned in the above conversation, the problem here was that the script was assigned to both the Player scene and as an Autoload. That Autoload reference was the problem and needed to be disabled or removed.