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

How to make DataStore not appear on leaderboard?

Asked by 9 years ago

I've started to get to grips with DataStore but I don't want the values I have stored to appear on the leaderboard - I just want them to be stored so they can appear elsewhere (i.e, a GUI). How would I do this?

local DataStore = game:GetService("DataStoreService"):GetDataStore("Stats")

game.Players.PlayerAdded:connect(function(player)

    local stats = Instance.new("IntValue", player)
    stats.Name = "leaderstats" --Would I change this?

    local gold = Instance.new("IntValue", stats)
    gold.Name = "Gold"

    local key = "player-"..player.userId 

    local savedStats = DataStore:GetAsync(key)

    if savedStats then
        gold.Value = savedStats[1]
    else
        local newStats = {gold.Value}
        DataStore:SetAsync(key, newStats)
    end

end)


^Just testing it now which is why I only have one variable stored

1 answer

Log in to vote
0
Answered by
DataStore 530 Moderation Voter
9 years ago

The ROBLOX leaderboard only appears if the values are placed into something named "leaderstats" - The easiest way around this therefore is, obviously, to rename the object you're placing all the values in (as you also pointed out in your script).

Ad

Answer this question