Last time I didn't really get good answers so I'm hoping someone can help me this time.
I tried doing a "for loop" because everyone kept telling me to use that but I don't know how to though!
local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerWeaponStats")
game.Players.PlayerAdded:connect(function(player)
local key = "user-" .. player.userId
local store = DataStore:GetAsync(key)
store[1] = {}
local items = store[1]
for i,v in pairs(player.Class.WeaponStats:GetChildren()) do
if v:IsA("Configuration") then
for _, c in pairs(v:GetChildren()) do
if c:IsA("Configuration") then
for _, l in pairs(c:GetChildren()) do
if l:IsA("NumberValue") then
table.insert(l.Value)
end
end
end
end
end
end
print("Life")
end)
game.Players.PlayerRemoving:Connect(function(player)
local items = {}
for i,v in pairs(player.Class.WeaponStats:GetChildren()) do
if v:IsA("Configuration") then
for _, c in pairs(v:GetChildren()) do
if c:IsA("Configuration") then
for _, l in pairs(c:GetChildren()) do
if l:IsA("NumberValue") then
table.insert(l.Value)
end
end
end
end
end
end
local key = "user-" .. player.userId
DataStore:SetAsync(key, items)
print("Ended")
end)

3 comments
I still don't get it...
You're saving values to a table in player removed, then in player added you overwrite one of the values. Remove line 10 and 12. Second change line 60 as I said in the first paragraph. Third you need to rewrite lines 15-37, duplicating what you put in player added isn't going to work, and it seems you don't understand the basics enough to write it on your own. Read up on tables and loops and you m
will do