How to detect if player looks at object?

I would recommend doing a Sphere Trace, which essentially makes a capsule along the length of a given line (vector). If the trace hits something (if something enters the capsule), the trace can output what it was that it hit. You can then cast the result to the type of object you want to be looking at, and if the cast is successful, perform your next operation.