Data isn't saving while not erroring! why?
01 | local DS = game:GetService( "DataStoreService" ) |
02 | local InventoryStore = DS:GetDataStore( "InventoryStore" ) |
03 | local function save(player) |
04 | local playerInventory = player.Inventory:GetChildren() |
06 | for i = 1 , #playerInventory do |
07 | print (playerInventory [ i ] .Value) |
08 | table.insert(playerSave, playerInventory [ i ] .Value) |
10 | local success, failure = pcall ( function () |
11 | InventoryStore:SetAsync(player.UserId, playerSave) |
14 | print ( "Saving Success!" ) |
17 | warn( "Critical Save failure. Data of " ..player.Name.. " not saved." ) |
20 | game.Players.PlayerAdded:Connect( function (player) |
21 | local inventory = Instance.new( "Folder" , player) |
22 | inventory.Name = "Inventory" |
23 | Instance.new( "StringValue" , inventory).Value = "Test" |
24 | local success, PlayerComputerTable = pcall ( function () |
25 | InventoryStore:GetAsync(player.UserId) |
28 | print (PlayerComputerTable) |
31 | game.Players.PlayerRemoving:Connect( function (playerRemoving) |
34 | game:BindToClose( function () |
35 | for _, client in ipairs (game.Players:GetPlayers()) do |
36 | coroutine.wrap(save)(client) |
This code isn't erroring nor saving the Player's data.