Understand Helix Inventories and Item Instancing
masterIn Helix, inventories are distinct objects belonging to a character, which in turn belongs to a player.
Accessing a player's inventory:
Use client:GetCharacter():GetInventory() to retrieve the main inventory object.
Item Instancing:
Helix uses an asynchronous instancing system to prevent server freezes. Instead of returning the instance immediately, ix.item.Instance uses a callback.
ix.item.Instance(inventory, "item_id", data, x, y, callback)
inventory: The inventory object (use0for no inventory).item_id: The ID of the item to instance.data: (Optional) A table of custom data.x,y: The grid position in the inventory. Useinventory:FindEmptySlot()to find available space.callback: A function that receives the new item instance.
-- Instancing an item manually
local inventory = client:GetCharacter():GetInventory()
local x, y = inventory:FindEmptySlot()
ix.item.Instance(inventory, "test_item", { custom_data = true }, x, y, function(item)
print("New item instance created: " .. item:GetID())
end)