hi for the past few months i've been using this script for stats data store. but sometimes your data will be resetted. is there a way i could fix it?
local DataStore = game:GetService("DataStoreService") local myDataStore = DataStore:GetDataStore("EpicStorage") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local minutes = Instance.new("IntValue") minutes.Name = "Minutes" minutes.Parent = leaderstats local data local success, errormessage = pcall(function() data = myDataStore:GetAsync(player.UserId.."-minutes") end) if success then minutes.Value = data else print("Error when saving data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-minutes",player.leaderstats.Minutes.Value) end) if success then print("Data successfully saved!") else print("Data save is unsuccessful!") warn(errormessage) end end)