Help needed for adding a second leaderstats appear on the leaderboard with DataStore

Hello, I need help adding a second leaderstats named “Coins” appear on the leaderboard along with the first one which is “Jumps”. I’m by no means an expert scripter, I tried to do something but it just renames the “Jumps” leaderstats and doesn’t make the script work.

Below I’m leaving the original script:

local DataStoreService = game:GetService("DataStoreService")
local jumpsDatastore = DataStoreService:GetDataStore("JumpsDataStore")

local function loadData(datastore, key)
	local success, data = pcall(function()
		return datastore:GetAsync(key)
	end)

	return data
end

local function saveData(datastore, key, value)
	local success, err = pcall(function() 
		datastore:SetAsync(key, value)
	end)

	if err then print(err) end
end

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


	local jumpCount = Instance.new("IntValue")
	jumpCount.Name = "Jumps"
	jumpCount.Parent = leaderstats
	jumpCount.Value = loadData(jumpsDatastore, player.UserId) or 0
	
	player.CharacterAdded:Connect(function(character) 

		local humanoid = character:WaitForChild("Humanoid")
		local debounce = true

		humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
			if debounce == true then
				debounce = false
				if humanoid.Jump == true then
					jumpCount.Value = jumpCount.Value + 1
				end
				wait(0.2)
				debounce = true 
			end
		end)
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local jumps = player.leaderstats.Jumps
	saveData(jumpsDatastore, player.UserId, jumps.Value) 
end)

Thanks in advance to anyone trying to help :slight_smile:

Just add another number value using Instance.new()

-- Code
local coins = Instance.new("NumberValue")
coins.Parent = player.leaderstats
coins.Name = "Coins"

Simple as that.

I’ve added your code:

...

game.Players.PlayerAdded:Connect(function(player)
	local coins = Instance.new("NumberValue")
	coins.Parent = player.leaderstats
	coins.Name = "Coins"
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player 


	local jumpCount = Instance.new("IntValue")
	jumpCount.Name = "Jumps"
	jumpCount.Parent = leaderstats
	jumpCount.Value = loadData(jumpsDatastore, player.UserId) or 0

...

but now it does not display any leaderstats. Sorry for the stupid question and issue :sweat:

You are putting it before leaderstats is creating.
image

Put it after leaderstats.

...

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

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

	local jumpCount = Instance.new("IntValue")
	jumpCount.Name = "Jumps"
	jumpCount.Parent = leaderstats
	jumpCount.Value = loadData(jumpsDatastore, player.UserId) or 0

...

Sorry for the late response but thank you man!