Supposed to be a "global" leaderboard. Everything works fine besides the score which returns nil.

for i = 1, 100 do
    local Sam = script.Sample:Clone()
    Sam.Name = i
    Sam.Parent = script.Parent.Frame.ScrollingFrame
    Sam.UserPos.Text = "[" .. tostring(i) .. "]"
    Sam.Score.Text = "0"
    Sam.Username.Text = ""
    Sam.LayoutOrder = i
    script.Parent.Frame.ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 50 * i)
end
 
function UpdateGui()
    for i, v in pairs(game.Players:GetChildren()) do
        local Data = v.leaderstats.POTGS.Value
        local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("POTGSAVING")
        DataStore:SetAsync(v.UserId, Data)
    end
    local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("POTGSAVING")
    local Pages = DataStore:GetSortedAsync(false, 10)
    local Data = Pages:GetCurrentPage()
    for k, v in pairs(Data) do
        if tonumber(v.key) >= 1 then
            local Frame = script.Parent.Frame.ScrollingFrame:FindFirstChild(tostring(k))
            if Frame then
                Frame.Username.Text = game.Players:GetNameFromUserIdAsync(v.key)
                Frame.Score.Text = tostring(v.Value)
            end
        end
    end
end
 
while true do
    UpdateGui()
    wait(60)
end

In case you guys need to know what POTGS are or whatever.

local PointsService = game:GetService("PointsService")
local DSS = game:GetService("DataStoreService")
local Storage = DSS:GetDataStore("POTGSAVING")

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("Model")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local stringv = Instance.new("StringValue")
	stringv.Value = player:GetRoleInGroup(3333869)
	stringv.Parent = leaderstats 
	stringv.Name = "Rank"
	
	local points = (PointsService:GetGamePointBalance(player.userId))
	local stringp = Instance.new("StringValue")
	stringp.Value = points
	stringp.Name = "POTGS"
	stringp.Parent = leaderstats
	
 end)

game.Players.PlayerRemoving:Connect(function(player)
	   local SaveArray = {player.leaderstats.POTGS.Value}
	   Storage:SetAsync(player.UserId, SaveArray)
end)
	 

1 comment

0

PointService deprecated, userId deprecated, and DataStoreService cannot be used on the client. Restructure your code immediately