Some Players in my game have complained about having their Data being changed on entering a different server,some aren't affected and some say that it happens when I use the shutdown all servers button . Apparently the intValues that the datastores are saving are being replaced by random numbers?
I can't seem to find anything wrong with the scripts. I'm hoping someone else can review my script and reassure this should work as intended.
local saveAs = "HS" local dataStore = game:GetService("DataStoreService"):GetDataStore(saveAs) local Players = game:GetService("Players") Players.PlayerAdded:connect(function(player) local stats = player:WaitForChild("Hstats") local data = dataStore:GetAsync(player.UserId) if data then for name,value in next, data do stats[name].Value = value end end end) Players.PlayerRemoving:connect(function(player) local stats = player:FindFirstChild("Hstat") if stats then local data = {} for _,stat in ipairs(stats:GetChildren()) do data[stat.Name] = stat.Value end dataStore:SetAsync(player.UserId,data) end end) while wait(61) do for _, player in pairs(game.Players:GetChildren()) do local stats = player:FindFirstChild("Hstat") if stats then local data = {} for _,stat in ipairs(stats:GetChildren()) do data[stat.Name] = stat.Value end dataStore:SetAsync(player.UserId,data) end end end game.OnClose = function() wait(10) end
This is my best guess. The HS data store probably is used in more games then just yours. Other games are able to change your datastore also, so you should name it something unique, e.x. HS9280924. Also in case someone on scriptinghelpers is trolling, I would not actually post the datastore on here.