See this tutorial:
https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html?highlight=intersect_ray
In particular this part (for 3D just use get_world and Vector3 as parameters):
var space_state = get_world_2d().direct_space_state
# use global coordinates, not local to node
var result = space_state.intersect_ray(Vector2(0, 0), Vector2(50, 100))
You will get a dictionary as a response, and, I'm guessing, the collider is the node you intersect with.
{
position: Vector2 # point in world space for collision
normal: Vector2 # normal in world space for collision
collider: Object # Object collided or null (if unassociated)
collider_id: ObjectID # Object it collided against
rid: RID # RID it collided against
shape: int # shape index of collider
metadata: Variant() # metadata of collider
}