Well, I want to try to use the UpdateAsync, however, I saw that to use it you must make a separate function, but I don’t know how to put the location of the data that I want to save to that function.
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local configurationsData = DataStoreService:GetDataStore("ConfigurationsData0")
Players.PlayerRemoving:Connect(function(player)
local Send_Data = {
shadows = player.SettingsData.Graphics.Shadow.Value;
water = player.SettingsData.Graphics.Water.Value;
tree_texture = player.SettingsData.Graphics.Tree.Value;
fps =player.SettingsData.GameSettings.FPS.Value;
ping = player.SettingsData.GameSettings.Ping.Value;
gamma = player.SettingsData.GameSettings.BrilloVol.Value;
friends = player.SettingsData.GameSettings.PlayerChose.Value;
language = player.SettingsData.GameSettings.Language.Value;
SizeSlots = player.SettingsData.GameSettings.SlotsInventory.Value;
crouch = player.SettingsData.Keys.Crouch.Value;
}
local Success, err = pcall(function()
configurationsData:SetAsync(player.UserId, Send_Data)
end)
if (Success) then
print("Se ha guardado correctamente / Has been saved successfully")
else
print("hubo un error al guardar / there was an error saving")
warn(err)
end
end)
Is it basically the same one from roblox default DataStores but with 3 new features. UpdateAsync actually consider the old data before making changes to it.
Edit :- look like I also need to spend time to read the documentation again because a lot of changes already
local Success,Error
Success,Error = pcall(configurationsData.UpdateAsync,configurationsData,player.UserId,function(Data)
--Data is the data that your game currently has saved and to update it you just need to return a new value
--For example
return Send_Data
end)
Players.PlayerRemoving:Connect(function(player)
local Send_Data = {
shadows = player.SettingsData.Graphics.Shadow.Value;
water = player.SettingsData.Graphics.Water.Value;
tree_texture = player.SettingsData.Graphics.Tree.Value;
fps =player.SettingsData.GameSettings.FPS.Value;
ping = player.SettingsData.GameSettings.Ping.Value;
gamma = player.SettingsData.GameSettings.BrilloVol.Value;
friends = player.SettingsData.GameSettings.PlayerChose.Value;
language = player.SettingsData.GameSettings.Language.Value;
SizeSlots = player.SettingsData.GameSettings.SlotsInventory.Value;
crouch = player.SettingsData.Keys.Crouch.Value;
}
local Success,Error
Success,Error = pcall(configurationsData.UpdateAsync,configurationsData,player.UserId,function(Data)
--Data is the data that your game currently has saved and to update it you just need to return a new value
--For example
return Send_Data
end)
if (Success) then
print("Se ha guardado correctamente / Has been saved successfully")
else
print("hubo un error al guardar / there was an error saving")
warn(Error)
end
end)
Sorry for the inconvenience, I’m a little slow doing this kind of thing.