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)
end
end
local Success, Error = pcall(function()
local Data = PointsStore:GetSortedAsync(false,7)
local CashPage = Data:GetCurrentPage()
for Rank, SavedData in ipairs(CashPage) do
print("yes")
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
end
end
end)
end
while true do
for i,Frame in pairs(script.Parent:GetChildren()) do
if Frame.Name ~= "Sample" and Frame:IsA("Frame") then
Frame:Destroy()
end
end
LeaderBoardRefresh()
wait(ratetheoftheistheisaretherefreshhowlongcanyouevenmakeavariablepleasehelpitdoesntstopwuthelpmeplease)
end
(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.