function PopperCam.Update(O)if PopperEnabled then local O=Camera.Focus.p local D=Camera.CoordinateFrame local g=D.p+D.lookVector*NEAR_CLIP_PLANE_OFFSET local Y=Camera.ViewportSize local B={game.Workspace:WaitForChild("\068\101\098\114\105\115")}if Camera and(Camera.CameraSubject and Camera.CameraSubject.Parent)then table.insert(B,Camera.CameraSubject.Parent)end for O,D in pairs(PlayerCharacters)do table.insert(B,D)end for O,D in pairs(VehicleParts)do table.insert(B,D)end local f=0 for D,x in pairs(CAST_SCREEN_SCALES)do local o=ScreenToWorld(Y*x,Y,NEAR_CLIP_PLANE_OFFSET)local S=O+(o-g)local w,J=PiercingCast(S,o,B)local y=(J-o).Magnitude if y>f then f=y end end local x=(D.p-O).Magnitude if math.abs(x-LastZoomLevel)>.001 then LastPopAmount=0 end local o=math.max(f,LastPopAmount)if o>0 then Camera.CoordinateFrame=D+D.lookVector*o LastPopAmount=math.max(0,o-POP_RESTORE_RATE)end LastZoomLevel=x end end


function PopperCam:Update()
	if PopperEnabled then
		-- First, prep some intermediate vars
		local focusPoint = Camera.Focus.p
		local cameraCFrame = Camera.CoordinateFrame
		local cameraFrontPoint = cameraCFrame.p + (cameraCFrame.lookVector * NEAR_CLIP_PLANE_OFFSET)
		local screenSize = Camera.ViewportSize
		local ignoreList = {game.Workspace:WaitForChild("Debris")}
		if Camera and Camera.CameraSubject and Camera.CameraSubject.Parent then
		table.insert(ignoreList, Camera.CameraSubject.Parent)
		end
		for _, character in pairs(PlayerCharacters) do
			table.insert(ignoreList, character)
		end
		for _, basePart in pairs(VehicleParts) do
			table.insert(ignoreList, basePart)
		end
		
		-- Cast rays at the near clip plane, from corresponding points near the focus point,
		-- and find the direct line that is the most cut off
		local largest = 0
		for _, screenScale in pairs(CAST_SCREEN_SCALES) do
			local clipWorldPoint = ScreenToWorld(screenSize * screenScale, screenSize, NEAR_CLIP_PLANE_OFFSET)
			local rayStartPoint = focusPoint + (clipWorldPoint - cameraFrontPoint)
			local _, hitPoint = PiercingCast(rayStartPoint, clipWorldPoint, ignoreList)
			local cutoffAmount = (hitPoint - clipWorldPoint).Magnitude
			if cutoffAmount > largest then
				largest = cutoffAmount
			end
		end
		
		-- Then check if the player zoomed since the last frame,
		-- and if so, reset our pop history so we stop tweening
		local zoomLevel = (cameraCFrame.p - focusPoint).Magnitude
		if math.abs(zoomLevel - LastZoomLevel) > 0.001 then
			LastPopAmount = 0
		end
		
		-- Finally, zoom the camera in (pop) by that most-cut-off amount, or the last pop amount if that's more
		local popAmount = math.max(largest, LastPopAmount)
		if popAmount > 0 then
			Camera.CoordinateFrame = cameraCFrame + (cameraCFrame.lookVector * popAmount)
			LastPopAmount = math.max(0, popAmount - POP_RESTORE_RATE) -- Shrink it for the next frame
		end
		
		LastZoomLevel = zoomLevel
	end
end
