I have a game where I want to show the number of deaths a player has in the leaderboard, and I've made this for it in ServerScriptService:
game.Players.ChildAdded:connect(function(player)
local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = player.leaderstats
player.Changed:connect(function()
repeat wait() until player.Character
player.Character.Humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
end)
end)
end)
However, instead of increasing by one on the first death, it increases by four. But deaths after that increase it normally.

8 comments
Thank you very much, it did! :)
If this helped, accept answer or put in title [SOLVED] to mark as resolved
Good answer - also, always set the Parent property last for efficiency purposes. It's conceptually the same as why you shouldn't use Instance.new("instanceOfClass", Parent) (line 11-12).
Instance.new("instance",parent) is deprecated: https://wiki.roblox.com/index.php?title=Instance_(Data_Structure)
I didn't say it wasn't. I was letting you know that efficiency-wise you should be setting Parent after you have set all other properties.
IE -- Always do: .Text = "TEXT" ; .Parent = Parent over .Parent = Parent ; .Text = "TEXT"
Ah now i understood. I didn't quite understand what you said because my main language is not English. I understand very little, Thanks for warn this.
No worries, here is a full thread if you're interested: https://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296