Help With Global Leaderboard

I was making a global leaderboard for my game using this video How to Make A Global Leaderboard in Roblox Studio - YouTube.

When I finished the script it didnt work. Here it is

local DataStoreService = game:GetService("DataStoreService")
local PointsStore = DataStoreService:GetOrderedDataStore("pointsDataStore")

local part = script.Parent.Parent.Parent
local ratetheoftheistheisaretherefreshhowlongcanyouevenmakeavariablepleasehelpitdoesntstopwuthelpmeplease = 45

local function LeaderBoardRefresh()
	for i,Player in pairs(game.Players:GetPlayers()) do
		if Player:FindFirstChild("leaderstats") then
			PointsStore:SetAsync(Player.UserId.. "-Points", Player.leaderstats.Points.Value)
	local Success, Error = pcall(function()
		local Data = PointsStore:GetSortedAsync(false,7)
		local CashPage = Data:GetCurrentPage()
		for Rank, SavedData in ipairs(CashPage) do
			local Username = game.Players:GetNameFromUserIdAsync(tonumber(SavedData.key))
			local Cash = SavedData.value
			if Cash then
				local NewSample = script.Parent.Sample:Clone()
				NewSample.Visible = true
				NewSample.Parent = part.SurfaceGui.PlayHolder
				NewSample.Name = Username
				NewSample.Rank.Text = "#"..Rank
				NewSample.PName.Text = Username
				NewSample.Amount.Text = Cash

while true do
	for i,Frame  in pairs(script.Parent:GetChildren()) do
		if Frame.Name ~= "Sample" and Frame:IsA("Frame") then

(also yes, funny variable name)

I used a print and it stopped at line 20 (for Rank, SavedData in ipairs(CashPage) do)
the CashPage value turns out as “{}”
the Data value just prints “Instance”

I have tried running it in studio and in roblox but none seem to work heres a picture

Another thing is that I’m new to devforum and I don’t have much experience with datastores.

Update: i switched my game over to ordered data stores because i realised that that was the problem.
I got the “yes” to print but it isnt working fully yet

just got it to work!
i put this in front of the user name variable to remove the “-Points”

local NewData = string.gsub(SavedData.key,"-Points","")

Not sure why some other people who I know arent one of the top are on there but at least it works!


Advice: This isn’t the correct place to put an issue like this, please put issues like this from now on in Scripting Support.

Ok. I will do this from now on.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.