How to tell if a pllayers camera is looking at a part?

I remember asking this same question on a discord server for scripting help, and I remember getting the answer, but that was awhile ago when I didn’t understand. I have gone to look back at it, but I can’t seem to find the messages. Does anyone know how to do this?

This API will fix it:

If you notice it is outside the camera, it is definitely not in sight.


In addition, you can try raycasting if there are walls obstructing the line of sight.

4 Likes

Their is a camera subject property which you can set with a script, (default is the characters humanoid).

You could also simply send out several ray casts from the camera’s pointing direction and see what it hits.

The difficulty is knowing what the player himself is paying attention to, or seeing himself with the camera’s field of view.
But somehow like this you could only know with peripherals such as eye tracking.

What is the use case and i may have some ideas of solutions for you.

1 Like

Thanks for the help both of you! I will try both to see which one functions better.

How would I get the second information returned as in the true/false?

EDIT: Nvm, I found out that they have an example.