I'm trying to make this Data Store save a player's backpack, and load it when they come back, but nothing happens, nothing returns with printing, no errors in the output. (Ignore the Kills part, it works fine)
if player_store:GetAsync("Kills") then Kills.Value = player_store:GetAsync("Kills") else Kills.Value = 0 end if player_store:GetAsync("Weapons") then for i,v in pairs (player.BackPack:GetChildren()) do v:remove() end local Weapons = player_store:GetAsync("Weapons") for i in Weapons do game.Lighting:FindFirstChild(i):Clone().Parent = player.BackPack end end end) game.Players.PlayerRemoving:connect(function(player) player_store = DataStore:GetDataStore(player.userId.."Z") if player_store:GetAsync("Kills") then player_store:SetAsync("Kills", player.leaderstats.Kills.Value) else player_store:SetAsync("Kills", player.leaderstats.Kills.Value) end if player_store:GetAsync("Weapons") then print 'its here' local Weapons = {} for i,v in pairs (player.BackPack:GetChildren()) do Weapons[v] = v end player_store:SetAsync("Weapons", Weapons) else local Weapons = {} for i,v in pairs (player.BackPack:GetChildren()) do Weapons[v] = v end player_store:SetAsync("Weapons", Weapons) end end) game.Close:connect(function() wait (5) end)
You could simplify a lot of the code you've posted. I remember helping you with something like this here, refer to that for further information.
Question: how are you verifying that these saved stats are specific to players?
What you have presented would update the data store Kills
with the last player's Kill
statistic, and your scripts would be based on that last player's stat, but will affect all players...
In other words, if one player works hard to achieve a high kill stat, player after him will ruin that achievement because their stat will basically replace his.