local P=math.abs local function l(P)if P=="\067\097\109\101\114\097\083\117\098\106\101\099\116"then VehicleParts={}local P=Camera.CameraSubject if P then PopperEnabled=false for l,L in pairs(VALID_SUBJECTS)do if P:IsA(L)then PopperEnabled=true break end end if P:IsA("\086\101\104\105\099\108\101\083\101\097\116")then VehicleParts=P:GetConnectedParts(true)end if FFlagUserPortraitPopperFix then if P:IsA("\066\097\115\101\080\097\114\116")then SubjectPart=P elseif P:IsA("\077\111\100\101\108")then SubjectPart=P.PrimaryPart elseif P:IsA("\072\117\109\097\110\111\105\100")then SubjectPart=P.Torso end end end end end local function L(P,l)PlayerCharacters[P]=l end local function y(P)if P:IsA("\080\108\097\121\101\114")then P.CharacterAdded:connect(function(l)L(P,l)end)if P.Character then L(P,P.Character)end end end local function d(P)if P:IsA("\080\108\097\121\101\114")then PlayerCharacters[P]=nil end end local function c(P)if P=="\067\117\114\114\101\110\116\067\097\109\101\114\097"then local P=workspace.CurrentCamera if P then Camera=P if CameraChangeConn then CameraChangeConn:disconnect()end CameraChangeConn=Camera.Changed:connect(l)l("\067\097\109\101\114\097\083\117\098\106\101\099\116")end end end


local math_abs = math.abs

local function OnCameraChanged(property)
	if property == 'CameraSubject' then
		VehicleParts = {}

		local newSubject = Camera.CameraSubject
		if newSubject then
			-- Determine if we should be popping at all
			PopperEnabled = false
			for _, subjectType in pairs(VALID_SUBJECTS) do
				if newSubject:IsA(subjectType) then
					PopperEnabled = true
					break
				end
			end
			
			-- Get all parts of the vehicle the player is controlling
			if newSubject:IsA('VehicleSeat') then
				VehicleParts = newSubject:GetConnectedParts(true)
			end
			
			if FFlagUserPortraitPopperFix then
				if newSubject:IsA("BasePart") then
					SubjectPart = newSubject
				elseif newSubject:IsA("Model") then
					SubjectPart = newSubject.PrimaryPart
				elseif newSubject:IsA("Humanoid") then
					SubjectPart = newSubject.Torso
				end
			end
		end
	end
end

local function OnCharacterAdded(player, character)
	PlayerCharacters[player] = character
end

local function OnPlayersChildAdded(child)
	if child:IsA('Player') then
		child.CharacterAdded:connect(function(character)
			OnCharacterAdded(child, character)
		end)
		if child.Character then
			OnCharacterAdded(child, child.Character)
		end
	end
end

local function OnPlayersChildRemoved(child)
	if child:IsA('Player') then
		PlayerCharacters[child] = nil
	end
end

local function OnWorkspaceChanged(property)
	if property == 'CurrentCamera' then
		local newCamera = workspace.CurrentCamera
		if newCamera then
			Camera = newCamera
			
			if CameraChangeConn then
				CameraChangeConn:disconnect()
			end
			CameraChangeConn = Camera.Changed:connect(OnCameraChanged)
			OnCameraChanged('CameraSubject')
		end
	end
end
