local function t(t)local Z=Instance.new("\077\111\100\101\108",t)Z.Name="\108\101\097\100\101\114\115\116\097\116\115"local u=Instance.new("\083\116\114\105\110\103\086\097\108\117\101",Z)if Configurations.GRANT_ASSISTS then u.Name="\075\079 - \087\079 - \065"u.Value="\048 - \048 - \048"else u.Name="\075\079 - \087\079"u.Value="\048 - \048"end ScoreArray[t]={0;0;0}TeamManager:AssignPlayerToTeam(t)t.CharacterAdded:connect(function(Z)(Z:WaitForChild("\072\117\109\097\110\111\105\100")).Died:connect(function()PlayerManager:PlayerDied(t)wait(Configurations.RESPAWN_TIME)if GameRunning then t:LoadCharacter()end end)end)if PlayersCanSpawn then t:LoadCharacter()else DisplayManager:StartIntermission(t)end end local function Z(t)TeamManager:RemovePlayer(t)end local function u(t)local Z=tostring(ScoreArray[t][1])local u=tostring(ScoreArray[t][2])local B=tostring(ScoreArray[t][3])if not Configurations.GRANT_ASSISTS then if Z:len()<u:len()then while Z:len()<u:len()do Z=" "..Z end else while u:len()<u:len()do u=u.." "end end t.leaderstats["\075\079 - \087\079"].Value=Z..(" - "..u)else t.leaderstats["\075\079 - \087\079 - \065"].Value=Z..(" - "..(u..(" - "..B)))end end
-- Local Functions
local function OnPlayerAdded(player)
	-- Setup leaderboard stats
	local leaderstats = Instance.new("Model", player)
	leaderstats.Name = "leaderstats"

	local KWA = Instance.new("StringValue", leaderstats)
	if Configurations.GRANT_ASSISTS then
		KWA.Name = "KO - WO - A"
		KWA.Value = "0 - 0 - 0"
	else
		KWA.Name = "KO - WO"
		KWA.Value = "0 - 0"
	end

	ScoreArray[player] = { 0, 0, 0 } -- KOs, WOs, Assists

	TeamManager:AssignPlayerToTeam(player)

	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			PlayerManager:PlayerDied(player)
			wait(Configurations.RESPAWN_TIME)
			if GameRunning then
				player:LoadCharacter()
			end
		end)
	end)

	if PlayersCanSpawn then
		player:LoadCharacter()
	else
		DisplayManager:StartIntermission(player)
	end
end

local function OnPlayerRemoving(player)
	TeamManager:RemovePlayer(player)
end

local function UpdatePlayerScore(player)
	local KOString = tostring(ScoreArray[player][1])
	local WOString = tostring(ScoreArray[player][2])
	local AssistString = tostring(ScoreArray[player][3])

	if not Configurations.GRANT_ASSISTS then
		if KOString:len() < WOString:len() then
			while KOString:len() < WOString:len() do
				KOString = " " .. KOString
			end
		else
			while WOString:len() < WOString:len() do
				WOString = WOString .. " "
			end
		end
		player.leaderstats["KO - WO"].Value = KOString .. " - " .. WOString
	else
		player.leaderstats["KO - WO - A"].Value = KOString .. " - " .. WOString .. " - " .. AssistString
	end
end
