How to Make New player Stats

Hello,

I have trouble with my code and I can’t seem to find the problem…
The following code is located in ServerScriptService and is supposed to create new values in a player folder upon their arrival.

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local WhiteBall1 = Instance.new("IntValue")
	WhiteBall1.Name = "WhiteBall 1"
	WhiteBall1.Parent = leaderstats
	
	local WhiteBall2 = Instance.new("IntValue")
	WhiteBall2.Name = "WhiteBall 2"
	WhiteBall2.Parent = leaderstats
	
	local WhiteBall3 = Instance.new("IntValue")
	WhiteBall3.Name = "WhiteBall 3"
	WhiteBall3.Parent = leaderstats
	
	local WhiteBall4 = Instance.new("IntValue")
	WhiteBall4.Name = "WhiteBall 4"
	WhiteBall4.Parent = leaderstats
	
	local WhiteBall5 = Instance.new("IntValue")
	WhiteBall5.Name = "WhiteBall 5"
	WhiteBall5.Parent = leaderstats
	
	local SuperBall = Instance.new("IntValue")
	SuperBall.Name = "SuperBall"
	SuperBall.Parent = leaderstats
end)

Thank you for your help

1 Like

I’ve just tested it.
It works just fine?
Can you specify your problem?

I’m so sorry !

It worked once the game was published but not in Studio (don’t know why)…

Sorry again

1 Like

There is nothing wrong with your code so I am confused as to what you need help with? I think the issue you are facing is that not all the stats are showing because only four show. This is because the Roblox leaderstats feature only allows you to show four stats on the leaderboard.

The only way you will be able to show extra stats is by making your own custom player list/leaderboard or making a feature request asking to allow more stats to be shown.

Could you please eleaberate on this? What exactly doesn’t work?

Not to worry,
I think it was a glitch in Studio,
All is good now,
The problem used to be that the values didn’t exist at all in the player. There was no leaderstats or other values…