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()