This always seems to activate even when I'm not looking at the part. I thought it was supposed to only activate if I was looking at the part. How can I use this to activate only when Parts are in view?
local function op() for i,v in pairs(workspace:GetDescendants()) do if v:IsA("Part") then local visible = workspace.CurrentCamera:WorldToScreenPoint(v.Position) if visible == true then print(v.Name .. " is visible") end end end end game:GetService("RunService").Hearbeat:Connect(op)
you need two variables when using WorldToScreenPoint()
local variable,isVisible = workspace.CurrentCamera:WorldToScreenPoint()
the variable is the variable name and isVisible is a boolean value whether it's visible in Camera or not