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

How big of a table can you store inside of DataStoreService?

Asked by 8 years ago

So I've been making a game that saves a lot of information from the player and I sorta need to know what my limitations are. Here's the important stuff,

local DataStore = game:GetService("DataStoreService"):GetDataStore("SaveStatsStorage")
local key = "player-"..Player.userId

local SavedValues = DataStore:GetAsync(key)

    if SavedValues then
        Rounds.Value = SavedValues[1]
        SpongebobMapBeat.Value = SavedValues[2]
        SpaceMapBeat.Value = SavedValues[3]
        MemoryGameBeat.Value = SavedValues[4]
        Points.Value = SavedValues[5]
        MemoryGame2Beat.Value = SavedValues[6]
        DailyQuestionAnswered.Value = SavedValues[7]
        MarioLevelBeat.Value = SavedValues[8]
    else
        local ValuesToSave = {Rounds.Value, SpongebobMapBeat.Value, SpaceMapBeat.Value, MemoryGameBeat.Value, Points.Value, MemoryGame2Beat.Value, DailyQuestionAnswered.Value, MarioLevelBeat.Value}
        DataStore:SetAsync(key, ValuesToSave)
    end

So the tables getting quite big... I need to know how much I can put into the table and if there's a better way of saving a lot of values. Most of the values I'm going to be saving are bool values. Here's the whole script for context,

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

game.Players.PlayerAdded:connect(function(Player)
    local Stats = Instance.new("IntValue", Player)
    Stats.Name = "leaderstats"

    local Rounds = Instance.new("IntValue", Stats)
    Rounds.Name = "RoundsBeaten"
    Rounds.Value = 0

    local Points = Instance.new("IntValue", Stats)
    Points.Name = "Points"
    Points.Value = 0

    local SpongebobMapBeat = Instance.new("BoolValue",Player)
    SpongebobMapBeat.Name = "SpongebobMapBeat"
    SpongebobMapBeat.Value = false

    local SpaceMapBeat = Instance.new("BoolValue",Player)
    SpaceMapBeat.Name = "SpaceMapBeat"
    SpaceMapBeat.Value = false

    local MemoryGameBeat = Instance.new("BoolValue",Player)
    MemoryGameBeat.Name = "MemoryGameBeat"
    MemoryGameBeat.Value = false

    local MemoryGame2Beat = Instance.new("BoolValue",Player)
    MemoryGame2Beat.Name = "MemoryGame2Beat"
    MemoryGame2Beat.Value = false

    local DailyQuestionAnswered = Instance.new("BoolValue",Player)
    DailyQuestionAnswered.Name = "DailyQuestionAnswered"
    DailyQuestionAnswered.Value = false

    local MarioLevelBeat = Instance.new("BoolValue",Player)
    MarioLevelBeat.Name = "MarioLevelBeat"
    MarioLevelBeat.Value = false


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

    local SavedValues = DataStore:GetAsync(key)

    if SavedValues then
        Rounds.Value = SavedValues[1]
        SpongebobMapBeat.Value = SavedValues[2]
        SpaceMapBeat.Value = SavedValues[3]
        MemoryGameBeat.Value = SavedValues[4]
        Points.Value = SavedValues[5]
        MemoryGame2Beat.Value = SavedValues[6]
        DailyQuestionAnswered.Value = SavedValues[7]
        MarioLevelBeat.Value = SavedValues[8]
    else
        local ValuesToSave = {Rounds.Value, SpongebobMapBeat.Value, SpaceMapBeat.Value, MemoryGameBeat.Value, Points.Value, MemoryGame2Beat.Value, DailyQuestionAnswered.Value, MarioLevelBeat.Value}
        DataStore:SetAsync(key, ValuesToSave)
    end
end)

And and all help would be great (= thanks

1 answer

Log in to vote
2
Answered by 8 years ago

There is a wiki article on this, however so long as your values aren't absolutely massive, that should be fine.

You could potentially break them up into separate stores if it proves too much.

1
Thanks (= User#11440 120 — 8y
Ad

Answer this question