How to display my values on the leaderboards?

I’m writing a simple DataStore script and I want the leaderboards to also display my different IntValues

The issue is that it doesn’t display any of the IntValues. I wrote this out from a tutorial and it showed the values on the tutorial maker’s screen. I’m suspecting it has something to do with a ROBLOX update. If I’d have to write additional code, then I could ask for help on here. I have a picture of this incident:

I haven’t tried anything so far, aside from writing this post :D.!

Here’s the code:

DSS = game:GetService("DataStoreService")
myDS = DSS:GetDataStore("myDS")
game.Players.PlayerAdded:Connect(function(player) -- tutkii, että onko pelaaja liittynyt peliin
	
	local Leaderboards = Instance.new("Folder") -- luo kansion
	Leaderboards.Name = "Leaderboards"
	Leaderboards.Parent = player
	
	local VR = Instance.new("IntValue") --IntValue sisältää tietoa pelaajan statseista
	VR.Name = "VR"
	VR.Parent = Leaderboards
	
	local Coins = Instance.new("IntValue")  --for code reviewers, the coins are not a currency, just so you know :)
	Coins.Name = "Coins"
	Coins.Parent = Leaderboards
	
	local playerID = "Player_" ..player.UserId -- tunnistaa pelaajan käyttäjän
	
	--tässä tieto latautuu
	
	local data
	local success, errormessage = pcall(function()
		data = myDS:GetAsync(playerID) -- Async mahdollistaa datan tulon samalla kun teet jotain muuta pelissä(kai?)
	end)
	
	VR.Value = data
    
	if success then
		VR.Value = data.VR
		Coins.Value = data.Coins
		--Jos data latautuu onnistuneesti, datan arvo = VR:n arvo
	end

end)

--Kuinka tallentaa tietoa

game.Players.PlayerRemoving:Connect(function(player) -- tutkii, että onko pelaaja lähtemässä pelistä
	local playerID = "Player_" ..player.UserId
	
	local data = {
		VR = player.Leaderboards.VR.Value;
		Coins = player.Leaderboards.Coins.Value
		}
	
	local success,errormessage = pcall(function()
	myDS:GetAsync(playerID,data)	
	end)
	if success then
		print("Data save successful")
	else
		print("An error occured while trying to save data")
		warn(errormessage)
	end
end)

All help is appreciated!

Unfortunately, roblox uses a strict name detection for leaderboards, you’ll have to name your folder “leaderstats”

2 Likes

Now it works. Thanks for the help :slight_smile: .