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

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
