i made this script when a player kills someone they get a KOs and i tried making the thing that i was asking but this wont work

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
                killer.TeamColor = BrickColor.new(killerteam)
		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

i tried that but it didnt work

######Edited 13:10 11/10 ~ Format your code properly