Issue with leaderstats

Okay, and then when you will back, we continue?

I could help you in about 3 and a half hours, but you might want to look for help in the meantime

I’ll wait for you when you come back

1 Like

And also, can I add you just in case?

Okay, anyways cya and good luck! C:

1 Like

I could offer help right now if you are available

1 Like

Hi again, sure, I can continue

Alright invite me to teamcreate

1 Like

Okay 1 second. Oh wait, you should add me in friends

Sorry but i am just offering temporarily help i can help you with this but not anything beyond that

Yea I know, I said , that roblox studio wrote this

Since player.CharacterAdded is being connected inside PlayerAdded, each character respawn will set up a new Died event, which will lead to duplicated connections… (duplicated deaths)

local PlayerService = game:GetService("Players")

PlayerService.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = leaderstats

	local kills = Instance.new("IntValue")
	kills.Name = "Kills"
	kills.Parent = leaderstats

	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			deaths.Value += 1
			local tag = humanoid:FindFirstChild("creator")
			if tag and tag.Value and tag.Value:IsA("Player") then
				local killerKills = tag.Value:FindFirstChild("leaderstats"):FindFirstChild("Kills")
				if killerKills then
					killerKills.Value += 1
					warn(tag.Value.Name, "Killed", player.Name)
				end
				tag:Destroy()
			end
		end)
	end)
end)

This should fix that.

1 Like

Alright i can temporarily friend, one second

1 Like

I saw that aswell but when i tested it it didn’t duplicate, he could definitely change that tho. Anyways the problem now is something beyond the leaderstats script.

Alright, I added you in teamcrate

It’s just that, that could lead to what is happening. So I went with a re-wright. Also took out that redundant health check.

SOLVED!!! Thank you very much hylas16

2 Likes