Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with global leaderboard?

Asked by
jdc892 4
5 years ago

I'm fine with the ordered datastore thing, but in my data storing I store the data in a data named the userid of the player. So each player has their own datastore, how do I get all of them then order it?

Here is the part of my datastore script that saves the money:

    local id = player.UserId
    local suffixes = Settings.MoneySuffixes

    --// Folders \\--
    local stats = Instance.new("Folder", player)
    stats.Name = "Stats"

    local lead = Instance.new("Folder", player)
    lead.Name = "leaderstats"

    local inv = Instance.new("Folder", player)
    inv.Name = "Inventory"

    --// Values \\--
    local cash = Instance.new("NumberValue")
    cash.Value = Settings.CashForNewPlayers
    cash.Name = "PureCash"
    cash.Parent = stats

    local scash = Instance.new("StringValue")
    scash.Value = "$ "..cash.Value
    scash.Name = "Cash"
    scash.Parent = lead

    local isHolding = Instance.new("BoolValue")
    isHolding.Name = "isHolding"
    isHolding.Parent = stats

    --// Data functions \\--
    cash.Changed:connect(function()
        scash.Value = maths.GetSuffix(cash.Value)
    end)

    --// Data storing \\--

    local save = DataStore:GetAsync(id)
    if save then
        if save[1] then
            cash.Value = save[1]
        end
    else
        for i,v in pairs(game.ReplicatedStorage.Items:GetChildren()) do
            if Settings.ItemsForNewPlayers[v.Name] then
                local item = Instance.new("NumberValue", inv)
                item.Name = v.Name
                item.Value = Settings.ItemsForNewPlayers[v.Name]
            end
        end
    end
0
Seriously, what's the deal with everyone and data store problems?! Ziffixture 6913 — 5y
0
I did that, it somehow broke my entire game. jdc892 4 — 5y

Answer this question