WorldToViewportPoint, WorldToScreenPoint, SCP 173

I figured it out by myself.

local Part = workspace.Look -- This is the part I want this script to check if is visible
local Camera = workspace.Camera
local Character = game:GetService('Players').LocalPlayer.Character

local RunService = game:GetService('RunService')

local Parameters = RaycastParams.new()
Parameters.FilterDescendantsInstances = {Character, Part}
Parameters.FilterType = Enum.RaycastFilterType.Blacklist

RunService.RenderStepped:Connect(function()
	local Vector, OnScreen = Camera:WorldToViewportPoint(Part.Position)

	if OnScreen then
		if workspace:Raycast(Camera.CFrame.Position, Part.Position - Camera.CFrame.Position, Parameters) == nil then
			warn('Part is Onscreen')
		end
	end
	
end)

Put this in a local script in starter player. When the object is in view it will output so.

2 Likes