Best practices of DataStore?

I have seen many people who do the DataStore in 2 different types and I’m not sure which is the best practice.

  1. A single DataStore for all the players
local DataStoreService = game:GetService(”DataStoreService”)
local Players = game: GetService ("Players")
local gamedata = DataStoreService:GetDataStore("Data")

Players:PlayerAdded:Connect(function(Player)
    local success, val = pcall(function()
        gameData:GetAsync(Player.UserId)
    end)
    -- code
end)

And
2. Using a seperate DataStore for every player

local DataStoreService = game:GetService(”DataStoreService”)
local Players = game: GetService ("Players")

Players:PlayerAdded:Connect(function(Player)
    local playerData = DataStoreService:GetDataStore(Player.UserId)
    local success, val = pcall(function()
        playerData.GetAsync("whatever")
    end)
    -- code
end)

Which way is the best practice?

  1. Creating a single DataStore for all the players
    Or
  2. Creating a seperate DataStore for each Player???
3 Likes

you can also try datastore2
link: DataStore2 (kampfkarren.github.io)

1 Like

It depends, really.

If you’re creating a single DataStore (e.g. cash), use a single datastore and store each player’s data with

player.UserId..”-cash”

Or whatever your DataStore is called.

However, if you are using multiple DataStores (cash, wanted, etc), create a separate one for each player.

2 Likes

it does not really matter you can imagen datastores like folders on your computer

its like saying should I put all my pictures in 1 folder or should I put each picture in a separate folder

1 Like

I thought that there was a limit to how many DataStores each place could have? LIke for many things on Roblox.

1 Like

A single DataStore for all players will definitely be better, there isn’t any reason to create one for every player that I’m aware of, if anything that’s bad practice.

2 Likes

I would say making a single DS would be the best practice.

1 Like

I think number 2 is bad practice or at the very least unnecessary

1 Like

DataStore 2 was a good way to make versioned datastores before ROBLOX actually added them themselves, not worth using it now since it’ll only slow things down.

1 Like