My dataStore loads random data?
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.
03 | local dataStore = game:GetService( "DataStoreService" ):GetDataStore(saveAs) |
04 | local Players = game:GetService( "Players" ) |
06 | Players.PlayerAdded:connect( function (player) |
07 | local stats = player:WaitForChild( "Hstats" ) |
08 | local data = dataStore:GetAsync(player.UserId) |
10 | for name,value in next , data do |
11 | stats [ name ] .Value = value |
16 | Players.PlayerRemoving:connect( function (player) |
17 | local stats = player:FindFirstChild( "Hstat" ) |
20 | for _,stat in ipairs (stats:GetChildren()) do |
21 | data [ stat.Name ] = stat.Value |
23 | dataStore:SetAsync(player.UserId,data) |
28 | for _, player in pairs (game.Players:GetChildren()) do |
29 | local stats = player:FindFirstChild( "Hstat" ) |
32 | for _,stat in ipairs (stats:GetChildren()) do |
33 | data [ stat.Name ] = stat.Value |
35 | dataStore:SetAsync(player.UserId,data) |
42 | game.OnClose = function () |