Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I detect if the player can see an object?

I’m trying to make a horror game and I want to detect if the player can see the monster. How would I do this? Any help would be very appreciated!

3 comments

0

One way is, RAYCASTING!!!

0

@BashGuy10, can you explain how to do raycasting in an answer?

0

Try raycasting, it really helps. I don't know much about raycasting but search some up, i'll make some if you can't find the right tutorial!

1 answer

It's possible. I already made the script because I wanted to know how to do this and someone had a similar Question.

Research WorldToScreenPoint() and GetPartsObscuringTarget()

WorldToScreenPoint() -- This can tell you if a Part is visible(even through walls)

GetPartsObscuringTarget() -- This gives you a Table containing all the parts that is intersecting two given points

If you do it right then you can detect if the monster is in the player's screen. Unless if you want to know if the player is looking directly at the monster then use RayCasting or mouse.Target

This discussion is preserved as it was. New answers, comments, and votes are closed.