Okay so I’m making an inventory system (currently following a tutorial), and what’s supposed to happen is it is supposed to print the players inventory.
I have tried printing the player’s inventory before the code runs, and that actually worked!
But that’s not what I want, I want the inventory to print after the selected code runs.
(sorry if this was hard to understand)
Inventory server variables: inventory_server.all_inventories = {} inventory_server.max_stacks = 1 inventory_server.max_stack_data = { Tool = 1; Consumable = 5; Plant = 10; Resource = 10; Furniture = 1; Decoration = 1; Beans = 50; }
Check items function: --//Checking if has items function inventory_server.check_items(player, item_name) for _, stack_data in pairs(inventory_server.all_inventories[player].Inventory) do if stack_data.ItemName == item_name then return stack_data end end end
Adding items function: `–//Adding items
function inventory_server.add_items(player, tool)
--//Checks
if tool.ClassName ~= "Tool" then return end
local inv = inventory_server.all_inventories[player]
--//Adding the item
local found_stack = inventory_server.check_items(player, tool.Name)
if found_stack then
if table.find(found_stack.Items, tool) then
return
elseif #found_stack.Items < inventory_server.max_stack_data[found_stack.ItemType] then
table.insert(found_stack.Items, tool)
end
else
--//Creating a new stack
local stack = {
Description = tool.ToolTip;
Image = tool.TextureId;
ItemType = tool:GetAttribute("item_type");
IsDroppable = tool:GetAttribute("is_droppable");
ItemName = tool.Name;
Items = {tool};
StackId = inv.LastStackId
}
inv.LastStackId += 1
end
print(inv) --I want this to print right here
end`
Any help will be appreciated