of     1   

Clawandbyte
#141060927Monday, July 21, 2014 3:35 PM GMT

Hi. I was making a game, but then I realized that my save script doesn't seem to save specifically to each player. Rather, it saves one piece of data and then loads it for every player. Could I get a little help? Code: local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerData") --Saving Stats game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() -- Make sure we aren't looking for leaderstats before they are created wait(2) -- Just in case local stats = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #stats do -- creates a loop for all the stats print(stats[i].Name) datastore:SetAsync(stats[i].Name.. player.userId, stats[i].Value) end end) -- Loading Stats game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() -- Make sure we aren't looking for leaderstats before they are created wait(2) -- Just in case local stats2 = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #stats2 do stats2[i].Value = datastore:GetAsync(stats2[i].Name) end end) game.OnClose = function() print("Saving time!") wait(10) print("We should have saved now!") end
pa00
#141062424Monday, July 21, 2014 3:55 PM GMT

So you are setting data with this datastore:SetAsync(stats[i].Name.. player.userId, stats[i].Value) And getting data with this stats2[i].Value = datastore:GetAsync(stats2[i].Name) You should be getting data with this stats2[i].Value = datastore:GetAsync(stats2[i].Name.. player.userId)
Clawandbyte
#141063641Monday, July 21, 2014 4:09 PM GMT

Right. Thanks for the help.

    of     1