In the current game I am creating I want to make it so when the raycast is touching an enemy and you left click, it does damage.

I see 2 errors for my code

identifier "raycast" not declared in current scope
node not found "raycast3d" relative to root/node3d

`var health = 100

func _ready():
var raycast = get_parent().get_node("/player/head/Camera3D/RayCast3D")

func _physics_process(delta):

if Input.is_action_just_pressed("click") and raycast.is_colliding():
	health -= 10
	
	
	
if health <= 0:
	queue_free()`

Can you post a screenshot of your scene structure to see how your nodes are set up and named?

But what I already can tell you is that you should declare the raycast variable outside of the ready function, else it is not accessible within other functions like _physics process. They way you declared it, it is a local variable and not accessible/known outside of the _ready function.

The easiest way to do this is to drag your raycast node into your script (outside any function) and before letting the mousebutton go hold CTRL.

You will get a variable for your raycast with the path to it:

@onready var ray_cast_3d: RayCast3D = $Camera3D/RayCast3D #Your node setup might be different
var health = 100

func _physics_process(delta):
    if Input.is_action_just_pressed("click") and raycast.is_colliding():
	   health -= 10   # Here you damage the player btw.

     if health <= 0:
	    queue_free()

You want it to do damage to you when your raycast hits an enemy?

    award I think this has potential for an interesting game. Health as your ammunition. I think there are quite some great game ideas born from those kind of happy little accidents. 🙂