Can't assign nodes in export variables?

Godot Version

godot 4

Question

I have a script that is handling item pickups in my game and I’m trying to assign a raycast3d in an export variable, which works, but everytime I try to use any of the ray’s functions, it gives a me a cannot call function on null value error. this also happens with all other nodes I try to assign to vars in this script, all are treated as null values despite being assigned. why might this be?

here’s the script in case that helps, I’m completely lost

extends Node3D

@export var velocity = 0
@export var Ray : RayCast3D
var Item 
var holding = false
var pickUpCool = 10
var pickUpCoolMax = 10
var evidence_dict = {
	"Stephanie's_Photos_House_": false,
	"Polaroid": false
}


func _process(delta):
	pickUpCool -= 1
	if Input.is_action_just_pressed("Throw") && holding:
		_throw()
	if Input.is_action_pressed("Throw") && !holding && pickUpCool <= 0:
		_pickUp()
		

func _pickUp():
	if Ray.is_colliding():
		var obj = Ray.get_collider()
		if (obj.is_in_group("ItemPickups")):
			Item = obj
			Item.reparent(self, true)
			Item.global_position = global_position
			Item.global_rotation = global_rotation
			Item.freeze = true
			holding = true;
			pickUpCool = pickUpCoolMax
		elif (obj.is_in_group("EvidencePickups")):
			if (evidence_dict.has(obj.name)):
				evidence_dict[obj.name] = true
				obj.queue_free()
				pickUpCool = pickUpCoolMax



func _throw():
	pickUpCool = pickUpCoolMax
	Item.freeze = false
	Item.reparent(get_tree().get_root(), true)
	Item.apply_impulse((Vector3(0,0,0) + -Item.transform.basis.z)* velocity, -Item.transform.basis.z)
	Item.set_angular_velocity((Vector3(5,6,6) * -Item.transform.basis.z)* 3)
	holding = false;

Can you add this snippet? And post what it prints?

func _ready() -> void:
    print("I am %s and my ray is " % get_path(), Ray)

interestingly, it put out two outputs

I am /root/Hands and my ray is
I am /root/WorldTest1/Player/head/Camera3D/Hands and my ray is RayCast3D:<RayCast3D#33202111919>

So you have a global copy of this script, it must be removed, @exports cannot be assigned in Globals

where would that be? I don’t see it in the file manager

In the project settings under the “Globals” (4.3) or “Autoload” (< 4.2) tab

thank you so much, I haven’t had much experience with global scripts yet.