Can't fix errors

Godot Version

Godot 4.2.2 stable official

Question

I fiinshed this tutorial https://www.youtube.com/watch?v=UYQfVx1EIW8&list=PLjW_5zAXqqlnsseigSqdExhPbmTK29okt&index=4&t=245s, and I was learning stuff by adding more to it, after 5 hours or so I got a few errors, the thing is I didn’t touch that stuff it worked for all this time


@onready ray_cast_2d = $CanvasLayer/RayCast2D

↑ No, that is incorrect; in the node tree, RayCast2D is a child of Player, not CanvasLayer.

Stick with what you already have and don’t change that line:

@onready ray_cast_2d = $RayCast2D

Can we see your shoot function?

1 Like

Thanks for the catch

1 Like

Maybe use an export var for the raycast2D?

@export var ray_cast_2d:RayCast2D

In place of

@onready var ray_cast_2d= $RayCast2D


if I gray out MuzzleFlash then the error would move to the next line (MuzzleFlashTimer), its like it doesnt recognize nodes anymore

Made a new project same tutorial, turns out I made a mistake of autoloading the player script to make global variables instead of making a global script, after removing it from auto load everything works fine