function Entered(h)if h:findFirstChild("\108\101\097\100\101\114\115\116\097\116\115")==nil then stats=Instance.new("\073\110\116\086\097\108\117\101")stats.Parent=h stats.Name="\108\101\097\100\101\114\115\116\097\116\115"money=Instance.new("\073\110\116\086\097\108\117\101")money.Value=0 money.Name="\077\111\110\101\121"money.Parent=stats ao=Instance.new("\073\110\116\086\097\108\117\101")ao.Value=0 ao.Name="\065\108\114\101\097\100\121\079\119\110\101\100"ao.Parent=h end end game.Players.PlayerAdded:connect(Entered)p=game.Players:GetChildren()for h=1,#p,1 do Entered(p[h])end print("\076\105\110\107\101\100\076\101\097\100\101\114\098\111\097\114\100 \115\099\114\105\112\116 \118\101\114\115\105\111\110 \053\046\048\048 \108\111\097\100\101\100")stands={}CTF_mode=false function handleKillCount(h,o)local W=getKillerOfHumanoidIfStillInGame(h)if W~=nil then local h=W:findFirstChild("\108\101\097\100\101\114\115\116\097\116\115")if h~=nil then local Q=h:findFirstChild("\075\079\115")if W~=o then Q.Value=Q.Value+1 else Q.Value=Q.Value-1 end end end end function onPlayerEntered(h)if CTF_mode==true then local o=Instance.new("\073\110\116\086\097\108\117\101")o.Name="\108\101\097\100\101\114\115\116\097\116\115"captures.Parent=o while true do if h.Character~=nil then break end wait(5)end o.Parent=h else local o=Instance.new("\073\110\116\086\097\108\117\101")o.Name="\108\101\097\100\101\114\115\116\097\116\115"local W=Instance.new("\073\110\116\086\097\108\117\101")W.Name="\075\079\115"W.Value=0 W.Parent=o deaths.Parent=o while true do if h.Character~=nil then break end wait(5)end local Q=h.Character.Humanoid Q.Died:connect(function()onHumanoidDied(Q,h)end)h.Changed:connect(function(o)onPlayerRespawn(o,h)end)o.Parent=h end end


function Entered(p)

if p:findFirstChild("leaderstats") == nil then

stats = Instance.new("IntValue")
stats.Parent = p
stats.Name = "leaderstats"

money = Instance.new("IntValue")
money.Value = 0 -- How much money each player starts with.
money.Name = "Money"
money.Parent = stats

ao = Instance.new("IntValue")
ao.Value = 0
ao.Name = "AlreadyOwned"
ao.Parent = p

end
end

game.Players.PlayerAdded:connect(Entered)

p = game.Players:GetChildren()
for i = 1, #p do
Entered(p[i])
end
print("LinkedLeaderboard script version 5.00 loaded")

stands = {}
CTF_mode = false

function handleKillCount(humanoid, player)
	local killer = getKillerOfHumanoidIfStillInGame(humanoid)
	if killer ~= nil then
		local stats = killer:findFirstChild("leaderstats")
		if stats ~= nil then
			local kills = stats:findFirstChild("KOs")
			if killer ~= player then
				kills.Value = kills.Value + 1
				
			else
				kills.Value = kills.Value - 1
				
			end
		end
	end
end

function onPlayerEntered(newPlayer)

	if CTF_mode == true then

		local stats = Instance.new("IntValue")
		stats.Name = "leaderstats"


		captures.Parent = stats

		-- VERY UGLY HACK
		-- Will this leak threads?
		-- Is the problem even what I think it is (player arrived before character)?
		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		stats.Parent = newPlayer

	else

		local stats = Instance.new("IntValue")
		stats.Name = "leaderstats"

		local kills = Instance.new("IntValue")
		kills.Name = "KOs"
		kills.Value = 0

		kills.Parent = stats
		deaths.Parent = stats

		-- VERY UGLY HACK
		-- Will this leak threads?
		-- Is the problem even what I think it is (player arrived before character)?
		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		local humanoid = newPlayer.Character.Humanoid

		humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )

		-- start to listen for new humanoid
		newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )


		stats.Parent = newPlayer

	end

end
