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


local math_abs = math.abs

local function OnCameraSubjectChanged()
	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

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 CameraSubjectChangeConn then
				CameraSubjectChangeConn:disconnect()
			end

			CameraSubjectChangeConn = Camera:GetPropertyChangedSignal("CameraSubject"):connect(OnCameraSubjectChanged)
			OnCameraSubjectChanged()
  		end
	end
end
