Detecting when a Camera is able to see a Part

I want to detect whenever the local player’s camera is able to see a Part, in it’s field of view.

I tried googling some solutions, and I did see some forums, but they didn’t 100% help me.

If you have any suggestions or solutions, you can comment them down below. Thank you.

local part = -- path to part

game["Run Service"].RenderStepped:Connect(function()
	local camCFrame = workspace.CurrentCamera.CFrame
	local unit = (part.Position - camCFrame.Position).Unit
	if unit:Dot(camCFrame.LookVector) > .5 then
		print("Can see")
	end
end)

Can it also be ran whenever the camera’s CFrame changes?

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.