You never HAVE to. Data is saved when the player leaves.
When data is saved as soon as the player leaves. Why shall you use :Save() to save data in the current data store to Roblox? Does this have any benefits?
ClearCache doesn’t clear their data. Search this thread for “GDPR” to figure out how to reset a players stats, but in that case you should preferably just manually set every key back to normal.
Hey! How well does datastore2 work with games that use roblox’s teleportation service?
I’ve been using datastore2 in my game Tower Defense Simulator, a front page game with 260+ mil visits, since August to fix previous saving issues with my game. Since then dataloss has significantly dropped but we still get reports from players claiming data loss frequently. Recently the issue affected FamedChris’s data in TDS as well.
It’s best practice to define every key you use in a script in the Combine, but if you can guarantee it’ll never be retrieved before combining, then it’s fine.
I’m a little lost with the actual saving part. I can get everything to work fine, it even says it saves when I leave the game in print. But it doesn’t actually save.
Print:
player left, saved Test1
local Datastore2 = require(game.ServerScriptService.DataStore2)
local defaultarm = 1
local defaultpic = 1
local defaultgol = 50
game.Players.PlayerAdded:Connect(function(player)
Datastore2.Combine("Test1", "Gold", "Armor", "Pickaxe")
--create values
local stats = Instance.new("Folder", player)
stats.Name = "Stats"
local gold1 = Instance.new("NumberValue", stats)
gold1.Name = "Gold"
local arm1 = Instance.new("NumberValue", stats)
arm1.Name = "Armor"
local pic1 = Instance.new("NumberValue", stats)
pic1.Name = "Pickaxe"
--get stores
local goldstore = Datastore2("Gold", player)
local armstore = Datastore2("Armor", player)
local picstore = Datastore2("Pickaxe", player)
local function updategold(gold)
gold1.Value = gold
end
local function updatearm(arm)
arm1.Value = arm
end
local function updatepic(pic)
pic1.Value = pic
end
--load initial data
updategold(goldstore:Get(defaultgol))
updatearm(armstore:Get(defaultarm))
updatepic(picstore:Get(defaultpic))
--update data
goldstore:OnUpdate(updategold)
armstore:OnUpdate(updatearm)
picstore:OnUpdate(updatepic)
end)
local goldstore = Datastore2("Gold", player)
local armstore = Datastore2("Armor", player)
local picstore = Datastore2("Pickaxe", player)
local function updategold(gold)
gold1.Value = gold
end
local function updatearm(arm)
arm1.Value = arm
end
local function updatepic(pic)
pic1.Value = pic
end
--load initial data
updategold(goldstore:Get(defaultgol))
updatearm(armstore:Get(defaultarm))
updatepic(picstore:Get(defaultpic))
--update data
goldstore:OnUpdate(updategold)
armstore:OnUpdate(updatearm)
picstore:OnUpdate(updatepic)
I tried adding it to the area where it changes the values, and it still doesnt work