Can't assign omniLight position on base nil

Godot Version

godot 4

Question

I’m trying to make a light that moves with the collision position of a raycast, but when I try to set a position, I get the error:
Invalid set index ‘global_position’ (on base: ‘Nil’) with value of type ‘Vector3’.

anyone know why? here’s the assignment for the light as well as the position

I’ve checked, the light is assigned in my scene

@export var lightPoint : OmniLight3D

lightPoint.global_position = Ray.get_collision_point()

lightPoint is null when you try to set its global_position. That’s what the error says. Why that is exactly is hard to say. The light could have been removed beforehand during runtime, or you have this script twice in your scene and the second one does not have lightPointassigned.