Leaderstats Malfunctioning

As you can see, there are leaderstats in my player, but they are not loading into the leaderboard.

Why?

Mind if you show what’s inside the leaderstats? And send your PlayerAdded code?

Screenshot 2022-03-10 at 9.20.45 PM
They are number values.

Script:

game.Players.PlayerAdded:Connect(function(player)
     local leaderstats = Instance.new("Folder",player)
     leaderstats.Name = "leaderstats"

     local coins = Instance.new("NumberValue", leaderstats)
     coins.Name = "Coins"
     coins.Value = 0

     local strength = Instance.new("NumberValue", leaderstats)
     strength.Name = "Strength"
     strength.Value = 0
end)
game.Players.PlayerAdded:Connect(function(player)
     local leaderstats = Instance.new("Folder")
     leaderstats.Name = "leaderstats"
     leaderstats.Parent = player

     local coins = Instance.new("NumberValue")
     coins.Name = "Coins"
     coins.Value = 0
     coins.Parent = leaderstats

     local strength = Instance.new("NumberValue")
     strength.Name = "Strength"
     strength.Value = 0
     strength.Parent = leaderstats
end)

Here’s what you need to know

4 Likes

This definitely weird behaviour since I copy and pasted the script that you gave in the replies and it worked just fine for me.
Maybe try restarting studio?
You should also test in a live game just in case you worry about it for a while and it turns out to just be in studio.

If it keeps happening ig you could try reinstalling studio and if that doesn’t work file a bug report.

A possible reason of that is because playerAdded function may not be fired since when it runs, the player was already added (happens only in studio for some reason)

Possible solution:

for _, player in pairs(game.Players:GetPlayers()) do
	playerAdded(player) --your function or script
end