`local DataStore = game:GetService("DataStoreService"):GetDataStore('ToolSave')
game.Players.PlayerAdded:Connect(function(plr)
 function loadstats()

    local WeaponLoadTable = plr:WaitForChild('Backpack'):GetChildren()
    for i = 1, #WeaponLoadTable do
        if DataStore:GetAsync(WeaponLoadTable[i].Name) == nil then
            print('New boi')
        else
            print(WeaponLoadTable[i].Name)
            WeaponLoadTable[i].Value = DataStore:GetAsync(WeaponLoadTable[i].Name)
        end
    end
end

loadstats()   

plr.CharacterRemoving:Connect(function()
plr.Character.Humanoid:UnequipTools()
end)
end)



game.Players.PlayerRemoving:Connect(function(plr)
    WeoponSaveTable = {}
      for i,v in pairs(plr.Backpack:GetChildren()) do
        table.insert(WeoponSaveTable,v:WaitForChild('IDNumber').Value)
        
    end
for i = 1,#WeoponSaveTable do
--    print(WeoponSaveTable[i].Name)
     DataStore:SetAsync(WeoponSaveTable[i].Name, WeoponSaveTable[i].Value)
print('jeff')

    end
end)



game:BindToClose(function()
    wait(5)
    print('Shutting down')
end)

Inventory is a folder with weopons and inside the weopons there are int values

2 comments

1

If you did everything right then why is there a problem? LOL

0

Not the solution, but check line 3