local r=game:GetService("\080\108\097\121\101\114\115")local m=game.Workspace.CurrentCamera local x=math.min local L=math.tan local s=math.rad local Q=math.huge local q=Ray.new local function h(r)return 1-(1-r.Transparency)*(1-r.LocalTransparencyModifier)end local function t(r,m)for m=#r,m+1,-1 do r[m]=nil end end local p,e,N do local function r()local r=s(m.FieldOfView)local x=m.ViewportSize local Q=x.X/x.Y N=2*L(r/2)e=Q*N end;(m:GetPropertyChangedSignal("\070\105\101\108\100\079\102\086\105\101\119")):Connect(r);(m:GetPropertyChangedSignal("\086\105\101\119\112\111\114\116\083\105\122\101")):Connect(r)r()p=m.NearPlaneZ;(m:GetPropertyChangedSignal("\078\101\097\114\080\108\097\110\101\090")):Connect(function()p=m.NearPlaneZ end)end local E={}do local m={}local function x()local r=1 E={}for m,x in pairs(m)do E[r]=x r=r+1 end end local function L(r)local function L(L)m[r]=L x()end local function s()m[r]=nil x()end r.CharacterAdded:Connect(L)r.CharacterRemoving:Connect(s)if r.Character then L(r.Character)end end local function s(r)m[r]=nil x()end r.PlayerAdded:Connect(L)r.PlayerRemoving:Connect(s)for r,m in ipairs(r:GetPlayers())do L(m)end x()end


local Players = game:GetService("Players")

local camera = game.Workspace.CurrentCamera

local min = math.min
local tan = math.tan
local rad = math.rad
local inf = math.huge
local ray = Ray.new

local function getTotalTransparency(part)
	return 1 - (1 - part.Transparency)*(1 - part.LocalTransparencyModifier)
end

local function eraseFromEnd(t, toSize)
	for i = #t, toSize + 1, -1 do
		t[i] = nil
	end
end

local nearPlaneZ, projX, projY do
	local function updateProjection()
		local fov = rad(camera.FieldOfView)
		local view = camera.ViewportSize
		local ar = view.X/view.Y

		projY = 2*tan(fov/2)
		projX = ar*projY
	end

	camera:GetPropertyChangedSignal("FieldOfView"):Connect(updateProjection)
	camera:GetPropertyChangedSignal("ViewportSize"):Connect(updateProjection)

	updateProjection()

	nearPlaneZ = camera.NearPlaneZ
	camera:GetPropertyChangedSignal("NearPlaneZ"):Connect(function()
		nearPlaneZ = camera.NearPlaneZ
	end)
end

local blacklist = {} do
	local charMap = {}

	local function refreshIgnoreList()
		local n = 1
		blacklist = {}
		for _, character in pairs(charMap) do
			blacklist[n] = character
			n = n + 1
		end
	end

	local function playerAdded(player)
		local function characterAdded(character)
			charMap[player] = character
			refreshIgnoreList()
		end
		local function characterRemoving()
			charMap[player] = nil
			refreshIgnoreList()
		end

		player.CharacterAdded:Connect(characterAdded)
		player.CharacterRemoving:Connect(characterRemoving)
		if player.Character then
			characterAdded(player.Character)
		end
	end

	local function playerRemoving(player)
		charMap[player] = nil
		refreshIgnoreList()
	end

	Players.PlayerAdded:Connect(playerAdded)
	Players.PlayerRemoving:Connect(playerRemoving)

	for _, player in ipairs(Players:GetPlayers()) do
		playerAdded(player)
	end
	refreshIgnoreList()
end
