How should I be using BindToClose()?

Thankyou! I was understanding the Datastores and limits wrong. This does make more sense, and it is going to make it easier for saving data without worrying, so if i had 2 datastores, i would not have to put a wait between them while saving?

You should only have one data store, but if you want to keep things organized you can use the second argument scope which works like a folder/dictionary

-- something like this
local mainData = {
   PlayerData = {
      player1 = {},
      player2 = {}
     -- etc 
   }
  Bans = {
    userId2 = true,
    userId3 = true
  }
}

Don’t say that. We never once said that you shouldn’t use BindToClose. We have them an answer but they were looking for full code, like you have spoonfed below.

Yes my bad, I was really confused because everyone were asking too many questions for something really simple, he just asked “which one should I use or which one is better”, the answer is really simple, point out which one is better or give a better solution.

2 Likes

I ment ordered datastores insted of normaldatastrores,
like this

function BindToCloseDataSaving()
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
local Success1, _ = pcall(function()
OrderedDataStore1:SetAsync(Key, Data1)
end)
local Success2, _ = pcall(function()
OrderedDataStore1:SetAsync(Key, Data2)
end)
end
game:BindToClose(BindToCloseDataSaving)

try to make this your last comment since this is not our topic

5 Likes

Hey @P1X3L_K1NG Sorry for the old bump, could you explain why #game.Players:GetPlayers <= 1? what if there is only 1 player in the server and the game is BindToClose? Will it not save the data for that only player?

2 Likes

Ill be honest all they really did was just argue with the guy who made the post for no reason what so ever. He literally asked which method is better to use idk what they were going on about

2 Likes