function onHumanoidDied(a,G)local h=G:findFirstChild("\108\101\097\100\101\114\115\116\097\116\115")if h~=nil then local J=h:findFirstChild("\087\105\112\101\111\117\116\115")J.Value=J.Value+1 local e=getKillerOfHumanoidIfStillInGame(a)handleKillCount(a,G)end end function onPlayerRespawn(a,G)if a=="\067\104\097\114\097\099\116\101\114"and G.Character~=nil then local a=G.Character.Humanoid local h=G a.Died:connect(function()onHumanoidDied(a,h)end)end end function getKillerOfHumanoidIfStillInGame(a)local G=a:findFirstChild("\099\114\101\097\116\111\114")if G~=nil then local a=G.Value if a.Parent~=nil then return a end end return nil end function handleKillCount(a,G)local h=getKillerOfHumanoidIfStillInGame(a)if h~=nil then local a=h:findFirstChild("\108\101\097\100\101\114\115\116\097\116\115")if a~=nil then local J=a:findFirstChild("\075\079\115")if h~=G then J.Value=J.Value+1 else J.Value=J.Value-1 end end end end function onPlayerEntered(a)local G=Instance.new("\073\110\116\086\097\108\117\101")G.Name="\108\101\097\100\101\114\115\116\097\116\115"local h=Instance.new("\073\110\116\086\097\108\117\101")h.Name="\075\079\115"h.Value=0 local J=Instance.new("\073\110\116\086\097\108\117\101")J.Name="\087\105\112\101\111\117\116\115"J.Value=0 h.Parent=G J.Parent=G while true do if a.Character~=nil then break end wait(5)end local e=a.Character.Humanoid e.Died:connect(function()onHumanoidDied(e,a)end)a.Changed:connect(function(G)onPlayerRespawn(G,a)end)G.Parent=a end game.Players.ChildAdded:connect(onPlayerEntered)




function onHumanoidDied(humanoid,player)
	local stats=player:findFirstChild("leaderstats")
	if stats~=nil then
		local deaths=stats:findFirstChild("Wipeouts")
		deaths.Value=deaths.Value + 1
		local killer=getKillerOfHumanoidIfStillInGame(humanoid)
		handleKillCount(humanoid,player)
	end
end

function onPlayerRespawn(property,player)
	if property=="Character" and player.Character~=nil then
		local humanoid=player.Character.Humanoid
		local p=player
		humanoid.Died:connect(function()
			onHumanoidDied(humanoid,p)
		end)
	end
end

function getKillerOfHumanoidIfStillInGame(humanoid)
	local tag=humanoid:findFirstChild("creator")
	if tag~=nil then
		local killer=tag.Value
		if killer.Parent~=nil then
			return killer
		end
	end
	return nil
end

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)
	local stats=Instance.new("IntValue")
	stats.Name="leaderstats"
	local kills=Instance.new("IntValue")
	kills.Name="KOs"
	kills.Value=0
	local deaths=Instance.new("IntValue")
	deaths.Name="Wipeouts"
	deaths.Value=0
	kills.Parent=stats
	deaths.Parent=stats

	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)

	newPlayer.Changed:connect(function(property)
		onPlayerRespawn(property,newPlayer)
	end)

	stats.Parent=newPlayer
end

game.Players.ChildAdded:connect(onPlayerEntered)

