Raycast variable always returns null

Godot Version

4.7

Question

no matter what I've tried this always returns null when I call it

@onready var ray_cast_3d: RayCast3D = $RayCast3D

the scene tree looks like this

nothing in it changes during run time the ray cast is enabled

I’ve also tried calling it both in the physics process function and the ready function

The path $RayCast3D is wrong. It should be $Area3D/RayCast3D

Edit: Sorry, my bad. I’m blind. Thanks for the heads up @rainerdeyke

Look again. The children of Area3D are not expanded (> symbol instead of v symbol), and Raycast3D is at the same indent level as Area3D. $RayCast3D should be correct.

Did you add this script as a global/autoload in the project settings?

no theres only the script i inted to have as a global there

I honestly have no idea what the issue was but I reopened godot today and it worked