How to check if a player cannot see a certain object?

Hello there,
I’ve been attempting to make a SCP, or more specific, SCP-173.
If you know about that it will move towards the closest humanoid when they are not looking.
I’ve never used or experimented with this before, so I am completely new to the idea of this.

This is what I have been trying:

local humr =  script.Parent.HumanoidRootPart
local cam = workspace.CurrentCamera

local view = cam:WorldToScreenPoint(humr.CFrame)

if not view then

   --following code here

end

Again never used WorldToScreenPoint() before, so I’d greatly appreciate some help.
Thanks.

I would suggest you to do that as well as cast a ray from the players head (?) to the object you want to check sight for. Considering the game you are making it also probably has fog so I would cast a ray just so that it ends at the fog endpoint.

1 Like