Gaining bounty after killing player

local Hit = {}

game.Players.PlayerAdded:Connect(function(Player)

	Player.CharacterAdded:Connect(function(Character)
		local folder = Instance.new("Folder", Character)
		folder.Name = "Hit player's folder"
		print("adding folder")
		Character:WaitForChild("Humanoid").Died:Connect(function()
			local findHitFolder = Character:WaitForChild("Hit player's folder")
			local bounty = Player.leaderstats:WaitForChild("Bounty")
			print("Player died")
			if findHitFolder then
				print("Found Folder")
				for _, v in pairs(findHitFolder:GetChildren()) do
					
					print("Finding children")
					print("Found + Adding bounty")
					local otherplayer = game.Players:WaitForChild(v.Name)
					local Enemybounty = otherplayer.leaderstats:WaitForChild("Bounty")
					if Enemybounty.Value < 0 then return end

					bounty.Value = bounty.Value - (bounty.Value * 0.15)
					Enemybounty.Value = Enemybounty.Value + (bounty.Value * 0.2)

				end
			end
		end)
	end)		
end)

Problem: Once you hit a player your name put into a folder. Inside the folder, the same person can be inside the folder. If there name in it twice then they gain bounty twice.

Solution: If there a way to detect if a player who already received their bounty to not get it again.

Etc: The script works but it not completed.

when you add a value to the findHitFolder, make sure that it doesn’t exist by checking with something like this:

function BulletHit(PlayerThatHit)
    -- other code
    -- adding the value to the folder
    if findHitFolder:FindFirstChild(PlayerThatHit.Name) == nil then
        -- add the value
    end
end
1 Like

Thank you, I appreciate it so much. It worked.