Using your original code, I was able to have it show whats being loaded properly by using this function:
local function LoadInventory(Player)
local Data = InventoryStore:GetAsync(Player.UserId)
local PlayerInventory
if Data then
local InventoryData = HttpService:JSONDecode(Data)
print(InventoryData,"This is what's being pulled when JSONDecoding")
PlayerInventory = Inventory.new(Player.UserId)
PlayerInventory = PlayerInventory:LoadFromData(InventoryData)
print(PlayerInventory, " This is what the inventory looks like when being loaded")
else
PlayerInventory = Inventory.new(Player.UserId)
end
InventoryTables[Player.UserId] = PlayerInventory
end
Your function PlayerInventory:LoadFromData() was returning the new data, however you had no to actually fetch the data from it; it caused your code to stay the same template every time it was ran instead of actually loading from your data.
One issue has come up though, and I think it’s my fault for how I structured the code
In here:
game.ReplicatedStorage.Inventory.AddItemBindable.Event:Connect(function(player,args)
print(args)
local PlayerInventory = InventoryTables[args.PlayerID]
warn(PlayerInventory)
local i = 1
while true do
if args["Item"..i] then
local AddItem = PlayerInventory:AddItem(args,i)
if AddItem then
PlayerInventory:StackFixer(args,i)
end
local FullFixer = PlayerInventory:FullFixer(args,i)
if FullFixer then
args["Item"..i] = nil
end
i+=1
else
args.Location.Finished:Fire(args)
i = 1
break
end
end
warn(Inventory)
end)
PlayerInventory previously had the functions of the module in them, like AddItem(), FullFixer(), StackFixer(), etc. Now, it’s the inventory data dictionary. What can I do about this?