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

How to Detect if a Player looks away from Part??

Its simple. What I wish to do is run function when player looks away from a part.

1 answer

✓ Accepted answer

I would use WorldToScreenPoint() to accomplish this. Note that it only detects the middle of the part, but looking up something for that should work. A code example would be:

local  pos, vis = workspace.CurrentCamera:WorldToScreenPoint(workspace.YourPartName.Position)

print(vis)

Hope this helps!

3 comments

0

vis is a boolvalue right??

0

if so, I'll have to do a continuous loop to constantly keep checking if the player is looking at part right??

0

Correct! The first value, "pos", is the position of the part. The second value, "vis", is a boolvalue to check if it is onscreen. You need a loop (this is in a LocalScript by the way) so I would recommend using .RenderStepped.

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