I'm making an ORB in a game and I don't know how to make it so if your camera is in it's line of view, it runs a piece of code. This obviously needs to be Local, not for every player. Thanks!
Example:
Player looks at orb
Code runs
Player looks away from the orb
code stops
You can try using WorldToScreenPoint function. It checks if a part's position is visible on the screen.
This code snippet utilizes that function to destroy a part.
local camera = workspace.CurrentCamera local humanoid = script.Parent:WaitForChild('Humanoid') local part = workspace.ORB local inView = false repeat local iView = workspace.CurrentCamera:WorldToScreenPoint(part.Position) if (iView) then inView = true end wait(2) until inView == true if inView == true then part:Destroy() end