Data Storing [NEED HELP]

This isn’t a scripting question per-sey, however I think it would fall under here or #help-and-feedback:game-design-support - I’ll move if needed.

However, I’m wondering how I would store the following data for a player:

  • Purchases
  • Progressive Quests completed & progress in them (ex: get 10 points using X tool)
  • Other data like this.

I am needing help with the scripting of it and the actual theory behind how DataStore works and how I would effectively store this.

Would I store it all in 1 DataStore? Would I store it in multiple?

Store all the data in a table. Purchases like game-passes can go in a different data store, but pretty much all in-game data like quests, currency, etc… go into the main data store for players.

You’d do something like this.

local Purchases = {} — save this to a Purchases data store for game-passes

local PlayerData = { — save this off to the PlayerData store
    Points = 100,
    Quests = {}
}

You should be learning how data stores work though.

That’s what I’m trying here.
So basically, you can use DataStore to store tables? Does that also work for sub tables?

DataStores can save all the primitive types and tables. There’s plenty of tutorials for you to go learn from.

1 Like

I always create a single DataStore in the DataStoreService. Every time a player joins, I create a table with all the data inside it, and then use GetAsync() to check for player data, and replace the table with the saved table. I then store the data with the player’s Id in a global variable as such:

_G.PlayerData = {}

I put separate tables inside the data table to hold purchases, and quests, e.g,

_G.PlayerData[Player] = {
    Quests = {
        TimeProgress = 0,
        Completed = 0,
        Goal = ""
    },
    Purchases = {
        --purchased inventory
    }
}

This also allows all server scripts to access the players data to process them.

1 Like