local V=game:GetService("\080\108\097\121\101\114\115")local q=game.Workspace.CurrentCamera local d=math.min local g=math.tan local P=math.rad local M=math.huge local b=Ray.new local function l(V)return 1-(1-V.Transparency)*(1-V.LocalTransparencyModifier)end local function t(V,q)for q=#V,q+1,-1 do V[q]=nil end end local N,k,Z do local function V()local V=P(q.FieldOfView)local d=q.ViewportSize local M=d.X/d.Y Z=2*g(V/2)k=M*Z end;(q:GetPropertyChangedSignal("\070\105\101\108\100\079\102\086\105\101\119")):Connect(V);(q:GetPropertyChangedSignal("\086\105\101\119\112\111\114\116\083\105\122\101")):Connect(V)V()N=q.NearPlaneZ;(q:GetPropertyChangedSignal("\078\101\097\114\080\108\097\110\101\090")):Connect(function()N=q.NearPlaneZ end)end local E={}do local q={}local function d()local V=1 E={}for q,d in pairs(q)do E[V]=d V=V+1 end end local function g(V)local function g(g)q[V]=g d()end local function P()q[V]=nil d()end V.CharacterAdded:Connect(g)V.CharacterRemoving:Connect(P)if V.Character then g(V.Character)end end local function P(V)q[V]=nil d()end V.PlayerAdded:Connect(g)V.PlayerRemoving:Connect(P)for V,q in ipairs(V:GetPlayers())do g(q)end d()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
