local a=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local L=a("\077\097\105\100")local I=a("\086\097\108\117\101\079\098\106\101\099\116")local R={}R.ClassName="\084\101\097\109\084\114\097\099\107\101\114"R.__index=R function R.new(a)local X=setmetatable({},R)X._player=a or error("\078\111 \112\108\097\121\101\114")X._maid=L.new()X.CurrentTeam=I.new()X.CurrentTeam.Value=nil X._maid:GiveTask(X.CurrentTeam)X._maid:GiveTask((X._player:GetPropertyChangedSignal("\084\101\097\109\067\111\108\111\114")):Connect(function()X:_updateCurrentTeam()end))X._maid:GiveTask((X._player:GetPropertyChangedSignal("\078\101\117\116\114\097\108")):Connect(function()X:_updateCurrentTeam()end))X._maid:GiveTask((X._player:GetPropertyChangedSignal("\084\101\097\109")):Connect(function()X:_updateCurrentTeam()end))X:_updateCurrentTeam()return X end function R.GetPlayer(a)return a._player end function R._updateCurrentTeam(a)if a._player.Neutral then a.CurrentTeam.Value=nil return end a.CurrentTeam.Value=a._player.Team end function R.Destroy(a)a._maid:DoCleaning()setmetatable(a,nil)end return R
--- Tracks a player's current team, since the Team property is unreliable
-- @classmod TeamTracker

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local Maid = require("Maid")
local ValueObject = require("ValueObject")

local TeamTracker = {}
TeamTracker.ClassName = "TeamTracker"
TeamTracker.__index = TeamTracker

function TeamTracker.new(player)
	local self = setmetatable({}, TeamTracker)

	self._player = player or error("No player")

	self._maid = Maid.new()

	self.CurrentTeam = ValueObject.new() -- Holds a Roblox team
	self.CurrentTeam.Value = nil
	self._maid:GiveTask(self.CurrentTeam)

	self._maid:GiveTask(self._player:GetPropertyChangedSignal("TeamColor"):Connect(function()
		self:_updateCurrentTeam()
	end))
	self._maid:GiveTask(self._player:GetPropertyChangedSignal("Neutral"):Connect(function()
		self:_updateCurrentTeam()
	end))
	self._maid:GiveTask(self._player:GetPropertyChangedSignal("Team"):Connect(function()
		self:_updateCurrentTeam()
	end))
	self:_updateCurrentTeam()

	return self
end

function TeamTracker:GetPlayer()
	return self._player
end

function TeamTracker:_updateCurrentTeam()
	if self._player.Neutral then
		self.CurrentTeam.Value = nil
		return
	end

	self.CurrentTeam.Value = self._player.Team
end

function TeamTracker:Destroy()
	self._maid:DoCleaning()
	setmetatable(self, nil)
end

return TeamTracker