I have a DataStore2 saving system for my game, and it work’s perfectly, until a player either crashes on their own accord or I shutdown the server that player is in manually. If a player leaves my game the data saves, but if a crash/servershutdown happens they lose all the data they gained/changed from when they joined.
This is the bulk of my code(Only showing one value since the rest is rinse and repeat):
game.Players.PlayerAdded:Connect(function(player)
local Holder = Instance.new("Folder")
Holder.Name = "Data"
Holder.Parent = player
local Value1 = Instance.new("NumberValue")
Value1.Name = "Strength"
Value1.Parent = Holder
DataStore2.Combine("Player Test", "Strength", "Toughness", "Stamina", "Breath", "Race", "Yen", "StatusLevel", "Hair2",
"PassFS", "Hair", "HairColor", "Eyes", "EyeColor", "Mouth", "AffinityColor", "Clothes", "HiltColor1", "WeaponSheathColor",
"BreathMastery", "Ability", "Skin", "Brows", "Acc", "EquipedSlotWeapon", "EquipedSlotHaori", "EquipedSlotAcc1", "EquipedSlotAcc2", "Rank",
"InvSlot1", "InvSlot1A", "InvSlot2", "InvSlot2A", "InvSlot3", "InvSlot3A", "InvSlot4", "InvSlot4A", "InvSlot5", "InvSlot5A", "InvSlot6",
"InvSlot6A", "InvSlot7", "InvSlot7A", "InvSlot8", "InvSlot8A", "InvSlot9", "InvSlot9A","InvSlot10", "InvSlot10A", "InvSlot11", "InvSlot11A",
"InvSlot12", "InvSlot12A", "InvSlot13", "InvSlot13A", "InvSlot14", "InvSlot14A", "InvSlot15", "InvSlot15A", "InvSlot16", "InvSlot16A", "Age",
"AgeTime","Family", "CharName", "CharStart", "HairDetail", "HiltColor2", "HiltColor3", "RankExp", "RankReq")
-------------------------------------------------
local StrengthStore = DataStore2("Strength", player)
if StrengthStore:Get() == nil then
StrengthStore:Set(1)
end
Value1.Value = StrengthStore:Get()
local function StrengthC(value)
if Value1 ~= nil and Value1.Value ~= nil then
StrengthStore:Set(Value1.Value)
end
end
Value1.Changed:Connect(StrengthC)
-------------------------------------------------
end)