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

Checking for part (inside Camera) within a chosen point?

So apparently the internal function FindPartOnRay is not a valid member of Camera.

This is crucial for a project I'm working on that has everything client sided. I tried Region3, but had the same issue. Is there any possible way I can check inside the camera for a part's existence within a chosen point?

2 comments

1

It isn't a method of the Camera object, it's a method of the Workspace.

0

Just Use, WorldToScreenPoint Or ViewPoint

1 answer

✓ Accepted answer
local Player = game.Players.LocalPlayer
local Cam = workspace.CurrentCamera;



	
game:GetService('RunService').RenderStepped:Connect(function()

for a,b in pairs(workspace:GetChildren()) do
	if b:IsA('BasePart') and b.Name ~= 'NoDetect' and b ~= workspace.Baseplate then
	local Pos, InView = Cam:WorldToScreenPoint(b.Position + Vector3.new(-b.Size.x/2,- b.Size.y/2, -b.Size.z/2))--<Uses the size of the obj the properly get the position of it since originaly the position of an object is the center
		if InView then
			b.Material = Enum.Material.Neon;
			print(b.Name..' Visible')
		else
			b.Material = Enum.Material.CorrodedMetal
			print(b.Name..' Not Visible')
		end 
	end
	end
end)

1 comment

0

Thanks, I got that to work!

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