Mouse Picking

I’ve worked out code to gather a ray from screen space to world space. I am having trouble detecting what lies on this ray. I am trying to select a certain triangle in a mesh of triangles.

I looked around on google and found nothing comprehensive for this.

Can anyone share pseudo code or explain the details on this?

Thanks! <3