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

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
