### Initialize Client Inventory Source: https://context7.com/asiandayboy/inventorymaker/llms.txt This section details the basic initialization and setup of the client-side inventory system. It includes defining custom item types, creating UI containers, and populating the inventory with initial data. ```APIDOC ## Initialize Client Inventory ### Description Basic initialization and setup of the client-side inventory system. ### Method Lua Scripting (Client-Side) ### Endpoint N/A (Client-side API) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local Players = game:GetService("Players") local InventoryMaker = require(game.ReplicatedStorage.IMC) -- Define your custom item type type Item = { ItemName: string, ItemDescription: string, ItemType: string, Quantity: number } -- Create a ScreenGui to contain all inventory UI local screenGui = Instance.new("ScreenGui") screenGui.Name = "InventoryGui" screenGui.Parent = Players.LocalPlayer.PlayerGui -- Initialize the framework InventoryMaker.Initialize(screenGui) -- Create containers with capacity and optional flags local mainContainer = InventoryMaker.Container("Main", 25, 0) local hotbarContainer = InventoryMaker.Container("Hotbar", 10, InventoryMaker.HOTBAR_COLLAPSE + InventoryMaker.HOTBAR_FILL_FIRST ) -- Populate with inventory data InventoryMaker.Populate(function() local items = { { ItemName = "Sword", ItemDescription = "A sharp blade", ItemType = "Weapon", Quantity = 1 }, false, -- Empty slot { ItemName = "Potion", ItemDescription = "Restores HP", ItemType = "Consumable", Quantity = 5 }, } return items, 35 -- items array, max capacity end) ``` ### Response None (Initializes client-side systems) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Manage Inventory Items with InventoryMaker Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Build, add, remove, and retrieve items from the inventory using InventoryMaker functions. Supports runtime item addition with or without stacking, item removal by slot index, and fetching item details. Also includes functions to check inventory size and capacity, toggle visibility, and get equipped items. ```lua -- Build the inventory with containers InventoryMaker.Build({ mainContainer, hotbarContainer }) -- Add new items at runtime local newSword = { ItemName = "Legendary Sword", ItemDescription = "A powerful weapon", ItemType = "Weapon", Quantity = 1 } local success = InventoryMaker.AddItem(newSword, false) if success then print("Item added successfully") end -- Add item with stacking local newPotion = { ItemName = "Potion", ItemDescription = "Restores HP", ItemType = "Consumable", Quantity = 3 } InventoryMaker.AddItem(newPotion, true) -- Will stack with existing potions -- Remove item InventoryMaker.RemoveItem(5) -- Remove item at slot index 5 -- Get current inventory size and capacity local currentSize = InventoryMaker.Size() local maxCapacity = InventoryMaker.Capacity() print(string.format("Inventory: %d/%d", currentSize, maxCapacity)) -- Get specific item local item, slotGui, filledGui = InventoryMaker.GetItem(3) if item then print("Item at slot 3:", item.ItemName) end -- Toggle inventory visibility InventoryMaker.ToggleInventory() -- Get equipped item local equippedItem, slotIndex = InventoryMaker.GetEquippedItem() if equippedItem then print("Currently equipped:", equippedItem.ItemName) end ``` -------------------------------- ### Server-Side Inventory Management using IMS in Lua Source: https://context7.com/asiandayboy/inventorymaker/llms.txt This Lua code demonstrates how to set up and manage inventories on the server using the IMS module. It covers defining item types, loading player data from DataStores, creating inventory containers, configuring stacking logic for items, building the inventory UI, and handling client-initiated events like switching items and receiving new items. ```lua local IMS = require(game.ServerScriptService.IMS) -- Define item type (must match client) type Item = { ItemName: string, ItemDescription: string, ItemType: string, Quantity: number } -- Load player inventory data local function getPlayerInventory(player) -- Load from DataStore return { { ItemName = "Sword", ItemDescription = "Sharp blade", ItemType = "Weapon", Quantity = 1 }, false, { ItemName = "Potion", ItemDescription = "Restores HP", ItemType = "Consumable", Quantity = 5 } } end -- Create containers local mainContainer = IMS.Container("Main", 25, 0) local hotbarContainer = IMS.Container("Hotbar", 10, IMS.HOTBAR_FILL_FIRST) -- Create inventory instance local playerInventories = {} game.Players.PlayerAdded:Connect(function(player) local inventoryData = getPlayerInventory(player) local inventory = IMS.Inventory(35, inventoryData) inventory:SetPlayer(player) -- Configure stacking (must match client) inventory:DefineStackingConfigs({ ValidateStackFunc = function(plr, targetItem, currItem) if targetItem.ItemName ~= currItem.ItemName then return false, 0 end local maxStack = 99 local combined = targetItem.Quantity + currItem.Quantity return true, math.max(0, combined - maxStack) end, UpdateStackFunc = function(plr, leftover, targetItem, currItem) if leftover <= 0 then targetItem.Quantity = targetItem.Quantity + currItem.Quantity else targetItem.Quantity = 99 currItem.Quantity = leftover end end, ValidateSplitFunc = function(plr, item) return item.Quantity > 1 end, UpdateSplitFunc = function(plr, currItem, newItem) local original = currItem.Quantity local split = math.floor(original / 2) currItem.Quantity = split newItem.Quantity = original - split return newItem, function() currItem.Quantity = original end end }) -- Build inventory inventory:Build({ mainContainer, hotbarContainer }) playerInventories[player] = inventory end) -- Handle remote events from client local switchRemote = game.ReplicatedStorage.SwitchItem switchRemote.OnServerEvent:Connect(function(player, slotIndex1, slotIndex2) local inventory = playerInventories[player] if inventory then inventory:Switch(slotIndex1, slotIndex2) end end) -- Add item to player inventory local function giveItem(player, item) local inventory = playerInventories[player] if inventory then local success = inventory:AddItem(item, true) return success end return false end ``` -------------------------------- ### Add Hover Prompts with Lua Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Demonstrates how to create and display detailed item information when hovering over an item in the inventory. It uses a GUI template and a render function to dynamically populate the hover prompt. Dependencies include the Instance class and InventoryMaker's DefineHoverPrompt function. ```lua -- Create hover prompt template local hoverPromptTemplate = Instance.new("Frame") hoverPromptTemplate.Size = UDim2.new(0, 200, 0, 100) hoverPromptTemplate.BackgroundColor3 = Color3.fromRGB(30, 30, 30) hoverPromptTemplate.BorderSizePixel = 2 hoverPromptTemplate.BorderColor3 = Color3.new(1, 1, 1) mainContainer:DefineHoverPrompt({ GuiTemplate = hoverPromptTemplate, FixedPosition = false, -- Follow mouse cursor Offset = Vector2.new(10, 10), ShowPromptAfterDragging = true, RenderFunc = function(item, hoverPromptGui, positionInfo) -- Clear previous content hoverPromptGui:ClearAllChildren() -- Add item details local nameLabel = Instance.new("TextLabel", hoverPromptGui) nameLabel.Text = item.ItemName nameLabel.Size = UDim2.new(1, 0, 0.3, 0) nameLabel.TextColor3 = Color3.new(1, 1, 1) nameLabel.BackgroundTransparency = 1 nameLabel.Font = Enum.Font.SourceSansBold local descLabel = Instance.new("TextLabel", hoverPromptGui) descLabel.Text = item.ItemDescription descLabel.Size = UDim2.new(1, -10, 0.4, 0) descLabel.Position = UDim2.new(0, 5, 0.3, 0) descLabel.TextColor3 = Color3.new(0.8, 0.8, 0.8) descLabel.BackgroundTransparency = 1 descLabel.TextWrapped = true local typeLabel = Instance.new("TextLabel", hoverPromptGui) typeLabel.Text = "Type: " .. item.ItemType typeLabel.Size = UDim2.new(1, 0, 0.3, 0) typeLabel.Position = UDim2.new(0, 5, 0.7, 0) typeLabel.TextColor3 = Color3.new(0.6, 0.6, 1) typeLabel.BackgroundTransparency = 1 -- Return cleanup function (optional) return function() print("Hover prompt closed for:", item.ItemName) end end }) ``` -------------------------------- ### Initialize Client Inventory with InventoryMaker Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Initializes the client-side inventory system for InventoryMaker. It requires the Roblox Players service and the IMC module. The function defines a custom item type, creates a ScreenGui for UI, and initializes the framework. It then defines main and hotbar containers with specific capacities and flags, populating them with initial item data. ```lua local Players = game:GetService("Players") local InventoryMaker = require(game.ReplicatedStorage.IMC) -- Define your custom item type type Item = { ItemName: string, ItemDescription: string, ItemType: string, Quantity: number } -- Create a ScreenGui to contain all inventory UI local screenGui = Instance.new("ScreenGui") screenGui.Name = "InventoryGui" screenGui.Parent = Players.LocalPlayer.PlayerGui -- Initialize the framework InventoryMaker.Initialize(screenGui) -- Create containers with capacity and optional flags local mainContainer = InventoryMaker.Container("Main", 25, 0) local hotbarContainer = InventoryMaker.Container("Hotbar", 10, InventoryMaker.HOTBAR_COLLAPSE + InventoryMaker.HOTBAR_FILL_FIRST ) -- Populate with inventory data InventoryMaker.Populate(function() local items = { { ItemName = "Sword", ItemDescription = "A sharp blade", ItemType = "Weapon", Quantity = 1 }, false, -- Empty slot { ItemName = "Potion", ItemDescription = "Restores HP", ItemType = "Consumable", Quantity = 5 }, } return items, 35 -- items array, max capacity end) ``` -------------------------------- ### Create Context Menus with Lua Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Shows how to implement right-click context menus for interacting with inventory items. This includes defining menu templates, rendering item-specific actions like 'Use' and 'Drop', and handling submenu options. It utilizes InventoryMaker's DefineContextMenus function. ```lua -- Create context menu template local contextMenuTemplate = Instance.new("Frame") contextMenuTemplate.Size = UDim2.new(0, 150, 0, 120) contextMenuTemplate.BackgroundColor3 = Color3.fromRGB(40, 40, 40) -- Define multiple context menus for nested menus InventoryMaker.DefineContextMenus({ { GuiTemplate = contextMenuTemplate, Offset = Vector2.new(5, 5), RenderFunc = function(slotIndex, item, contextMenuGui, filledGui, containerName) contextMenuGui:ClearAllChildren() -- Use button local useButton = Instance.new("TextButton", contextMenuGui) useButton.Text = "Use" useButton.Size = UDim2.new(1, 0, 0.25, 0) useButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60) useButton.Activated:Connect(function() print("Using item:", item.ItemName) InventoryMaker.CloseAllContextMenus() end) -- Drop button local dropButton = Instance.new("TextButton", contextMenuGui) dropButton.Text = "Drop" dropButton.Size = UDim2.new(1, 0, 0.25, 0) dropButton.Position = UDim2.new(0, 0, 0.25, 0) dropButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60) dropButton.Activated:Connect(function() InventoryMaker.RemoveItem(slotIndex) InventoryMaker.CloseAllContextMenus() end) -- More options button (opens submenu) local moreButton = Instance.new("TextButton", contextMenuGui) moreButton.Text = "More..." moreButton.Size = UDim2.new(1, 0, 0.25, 0) moreButton.Position = UDim2.new(0, 0, 0.5, 0) moreButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60) moreButton.Activated:Connect(function() InventoryMaker.OpenStaticContextMenu(containerName, 2) end) return function() print("Context menu closed") end end } }, InventoryMaker.SINGLE_CONTEXT_MENU_MODE, true) ``` -------------------------------- ### Configure Hotbar with Keybinds and Scrolling (Lua) Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Sets up the hotbar functionality with predefined keybinds (1-9, 0) and enables mouse wheel scrolling. It also defines behavior for when a key is pressed, providing visual feedback, and customizes the rendering of equipped slots with visual borders. ```lua -- Configure hotbar with keybinds 1-9 and 0 hotbarContainer:SetHotbarConfigs({ Keybinds = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, ScrollingHotbar = true, -- Enable mouse wheel scrolling OnKeyPress = function(item, filledGui, emptyGui, info) print("Equipped item:", item.ItemName) print("Slot index:", info.SlotIndex) print("Container index:", info.ContainerIndex) -- Visual feedback for equipped item filledGui.BackgroundColor3 = Color3.fromRGB(255, 200, 0) end }) -- Define equipped item rendering hotbarContainer:DefineRenderEquippedSlot(function(item, filledGui, emptyGui, info) -- Add visual indicator for equipped item local border = Instance.new("UIStroke", filledGui) border.Color = Color3.fromRGB(255, 255, 0) border.Thickness = 3 -- Return cleanup function to remove visual effects when unequipped return function(lastItem, lastFilledGui, lastEmptyGui, lastInfo) if lastFilledGui then local stroke = lastFilledGui:FindFirstChildOfClass("UIStroke") if stroke then stroke:Destroy() end end end end) ``` -------------------------------- ### Configure Remote Callbacks - Lua Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Sets up client-to-server and server-to-client communication for inventory operations using RemoteEvents. Handles actions like switching, stacking, splitting, equipping, and sorting items, as well as client-side updates for adding, removing, and capacity changes. ```lua -- CLIENT SIDE local RemoteEvent = game.ReplicatedStorage.InventoryEvent InventoryMaker.IMS.DefineRemotesToServer({ OnSwitch = function(slotIndex1, slotIndex2) RemoteEvent:FireServer("Switch", slotIndex1, slotIndex2) end, OnStack = function(targetSlotIndex, currSlotIndex) RemoteEvent:FireServer("Stack", targetSlotIndex, currSlotIndex) end, OnSplit = function(newSlotIndex, splitSlotIndex) RemoteEvent:FireServer("Split", newSlotIndex, splitSlotIndex) end, OnEquip = function(slotIndex) RemoteEvent:FireServer("Equip", slotIndex) end, OnSort = function(sorterName, ...) RemoteEvent:FireServer("Sort", sorterName, ...) end }) -- SERVER SIDE local RemoteEvent = game.ReplicatedStorage.InventoryEvent local AddItemRemote = game.ReplicatedStorage.AddItem local inventory = playerInventories[player] inventory:DefineRemotesToClient({ OnAdd = function(player, newItem, stackOnAdd) AddItemRemote:FireClient(player, newItem, stackOnAdd) end, OnRemove = function(player, slotIndex) RemoteEvent:FireClient(player, "Remove", slotIndex) end, OnIncreaseCap = function(player, containerIndex, amount) RemoteEvent:FireClient(player, "IncreaseCapacity", containerIndex, amount) end, OnDecreaseCap = function(player, containerIndex, amount) RemoteEvent:FireClient(player, "DecreaseCapacity", containerIndex, amount) end }) -- Handle server events RemoteEvent.OnServerEvent:Connect(function(player, action, ...) local inventory = playerInventories[player] if not inventory then return end if action == "Switch" then local slot1, slot2 = ... inventory:Switch(slot1, slot2) elseif action == "Stack" then local target, curr = ... inventory:Stack(target, curr) elseif action == "Split" then local newSlot, splitSlot = ... inventory:Split(newSlot, splitSlot) elseif action == "Equip" then local slotIndex = ... inventory:SetEquippedItem(slotIndex) elseif action == "Sort" then local sorterName = ... inventory:Sort(sorterName) end end) ``` -------------------------------- ### Implement Item Stacking and Splitting Logic (Lua) Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Configures the logic for stacking items, including validation to check if items can stack and how to handle overflow. It also defines the splitting mechanism, validating if an item can be split and updating quantities for both the original and new item, along with UI adjustments. ```lua InventoryMaker.DefineStackingConfigs({ ValidateStackFunc = function(targetItem, currItem) -- Check if items can stack if targetItem.ItemName ~= currItem.ItemName then return false, 0 end local maxStack = 99 local combined = targetItem.Quantity + currItem.Quantity if combined > maxStack then return true, combined - maxStack -- Return leftover amount end return true, 0 -- No leftovers end, UpdateStackFunc = function(leftover, targetItem, currItem, targetFilledGui, currFilledGui) if leftover <= 0 then -- All of currItem merged into targetItem targetItem.Quantity = targetItem.Quantity + currItem.Quantity else -- Partial merge targetItem.Quantity = 99 -- Max stack currItem.Quantity = leftover end -- Update UI local quantityLabel = targetFilledGui:FindFirstChild("QuantityLabel") if quantityLabel then quantityLabel.Text = tostring(targetItem.Quantity) end if currFilledGui and leftover > 0 then local currQuantityLabel = currFilledGui:FindFirstChild("QuantityLabel") if currQuantityLabel then currQuantityLabel.Text = tostring(leftover) end end end, ValidateSplitFunc = function(item) return item.Quantity > 1 -- Can only split if quantity > 1 end, UpdateSplitFunc = function(currItem, newItem, currFilledGui) local originalQuantity = currItem.Quantity local splitAmount = math.floor(originalQuantity / 2) currItem.Quantity = splitAmount newItem.Quantity = originalQuantity - splitAmount -- Update UI local quantityLabel = currFilledGui:FindFirstChild("QuantityLabel") if quantityLabel then quantityLabel.Text = tostring(currItem.Quantity) end -- Return new item and cleanup function return newItem, function() -- Undo split if operation is cancelled currItem.Quantity = originalQuantity if quantityLabel then quantityLabel.Text = tostring(originalQuantity) end end end }) ``` -------------------------------- ### Define Container Layouts Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Configure how containers are displayed with grid layouts and slot rendering. This includes setting up the visual appearance of both empty and filled inventory slots. ```APIDOC ## Define Container Layouts ### Description Configure how containers are displayed with grid layouts and slot rendering. ### Method Lua Scripting (Client-Side) ### Endpoint N/A (Client-side API) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua -- Define layout for main inventory mainContainer:DefineLayout({ ParentContainer = screenGui.MainFrame, CellSize = UDim2.new(0, 60, 0, 60), CellPadding = UDim2.new(0, 5, 0, 5), FillDirection = Enum.FillDirection.Horizontal, FillDirectionMaxCells = 5 }) -- Define empty slot appearance local emptySlotTemplate = Instance.new("Frame") emptySlotTemplate.BackgroundColor3 = Color3.fromRGB(50, 50, 50) emptySlotTemplate.Size = UDim2.new(1, 0, 1, 0) mainContainer:DefineEmptySlot({ GuiTemplate = emptySlotTemplate, RenderFunc = function(slotIndex, emptyGui, containerIndex) local label = Instance.new("TextLabel", emptyGui) label.Text = tostring(containerIndex) label.Size = UDim2.new(1, 0, 1, 0) label.TextColor3 = Color3.new(1, 1, 1) label.BackgroundTransparency = 1 end }) -- Define filled slot appearance local filledSlotTemplate = Instance.new("Frame") filledSlotTemplate.BackgroundColor3 = Color3.fromRGB(100, 100, 200) filledSlotTemplate.Size = UDim2.new(1, 0, 1, 0) mainContainer:DefineFilledSlot({ GuiTemplate = filledSlotTemplate, RenderFunc = function(slotIndex, item, filledGui, containerIndex) local nameLabel = Instance.new("TextLabel", filledGui) nameLabel.Text = item.ItemName nameLabel.Size = UDim2.new(1, 0, 0.7, 0) nameLabel.BackgroundTransparency = 1 nameLabel.TextColor3 = Color3.new(1, 1, 1) local quantityLabel = Instance.new("TextLabel", filledGui) quantityLabel.Text = tostring(item.Quantity) quantityLabel.Size = UDim2.new(1, 0, 0.3, 0) quantityLabel.Position = UDim2.new(0, 0, 0.7, 0) quantityLabel.BackgroundTransparency = 1 end }) ``` ### Response None (Configures UI rendering for containers) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Configure Search and Filtering in InventoryMaker Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Implement search and filtering capabilities for the inventory. This involves defining a search bar UI element and providing functions to transform search text and filter items. Custom filters can be defined based on item properties. ```lua -- Define search bar local searchBox = Instance.new("TextBox") searchBox.PlaceholderText = "Search items..." searchBox.Size = UDim2.new(0, 200, 0, 30) searchBox.Parent = screenGui InventoryMaker.DefineSearchBar({ SearchBarInputGui = searchBox, TransformTextFunc = function(text) return text:lower():gsub("%s+", "") -- Remove spaces, convert to lowercase end, FilterFunc = function(transformedText, item) local itemName = item.ItemName:lower() return itemName:find(transformedText) ~= nil end }) -- Define custom filters InventoryMaker.DefineCustomFilters({ Weapons = function(slotIndex, item, containerIndex) return item.ItemType == "Weapon" end, Consumables = function(slotIndex, item, containerIndex) return item.ItemType == "Consumable" end, Rare = function(slotIndex, item, containerIndex) return item.Rarity and item.Rarity >= 4 end }) -- Apply filter InventoryMaker.Filter("Weapons") -- Show only weapons -- Clear filter InventoryMaker.Filter(nil) -- Show all items ``` -------------------------------- ### Define Inventory Container Layouts and Slot Rendering Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Configures the visual layout and rendering of inventory containers using InventoryMaker. This snippet demonstrates defining a grid layout for the main inventory container with specific cell sizes, padding, and fill direction. It also shows how to define the appearance and rendering functions for both empty and filled inventory slots, including custom UI elements for item display. ```lua -- Define layout for main inventory mainContainer:DefineLayout({ ParentContainer = screenGui.MainFrame, CellSize = UDim2.new(0, 60, 0, 60), CellPadding = UDim2.new(0, 5, 0, 5), FillDirection = Enum.FillDirection.Horizontal, FillDirectionMaxCells = 5 }) -- Define empty slot appearance local emptySlotTemplate = Instance.new("Frame") emptySlotTemplate.BackgroundColor3 = Color3.fromRGB(50, 50, 50) emptySlotTemplate.Size = UDim2.new(1, 0, 1, 0) mainContainer:DefineEmptySlot({ GuiTemplate = emptySlotTemplate, RenderFunc = function(slotIndex, emptyGui, containerIndex) local label = Instance.new("TextLabel", emptyGui) label.Text = tostring(containerIndex) label.Size = UDim2.new(1, 0, 1, 0) label.TextColor3 = Color3.new(1, 1, 1) label.BackgroundTransparency = 1 end }) -- Define filled slot appearance local filledSlotTemplate = Instance.new("Frame") filledSlotTemplate.BackgroundColor3 = Color3.fromRGB(100, 100, 200) filledSlotTemplate.Size = UDim2.new(1, 0, 1, 0) mainContainer:DefineFilledSlot({ GuiTemplate = filledSlotTemplate, RenderFunc = function(slotIndex, item, filledGui, containerIndex) local nameLabel = Instance.new("TextLabel", filledGui) nameLabel.Text = item.ItemName nameLabel.Size = UDim2.new(1, 0, 0.7, 0) nameLabel.BackgroundTransparency = 1 nameLabel.TextColor3 = Color3.new(1, 1, 1) local quantityLabel = Instance.new("TextLabel", filledGui) quantityLabel.Text = tostring(item.Quantity) quantityLabel.Size = UDim2.new(1, 0, 0.3, 0) quantityLabel.Position = UDim2.new(0, 0, 0.7, 0) quantityLabel.BackgroundTransparency = 1 end }) ``` -------------------------------- ### Handle Character Death and Respawn - Lua Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Manages inventory state resets upon character death and respawn. On the client, it listens for character added and humanoid death events. On the server, it ensures temporary inventory states are cleared when a player's character dies. ```lua -- CLIENT SIDE local player = game.Players.LocalPlayer player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() -- Inventory automatically toggles off and clears state on death print("Character died, inventory reset") end) end) -- SERVER SIDE game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() local inventory = playerInventories[player] if inventory then IMS.Reset(inventory) -- Clear temporary states end end) end) end) ``` -------------------------------- ### Implement Sorting with InventoryMaker Source: https://context7.com/asiandayboy/inventorymaker/llms.txt Allows sorting of inventory items using custom sorting functions. You can define comparators for sorting by name, type, quantity, or rarity, with options for ascending or descending order. The sort function pushes empty slots to the end of the inventory. ```lua -- Define custom sorters InventoryMaker.DefineCustomSorters({ ByName = function(itemA, itemB) return itemA.ItemName < itemB.ItemName end, ByType = function(itemA, itemB) if itemA.ItemType ~= itemB.ItemType then return itemA.ItemType < itemB.ItemType end return itemA.ItemName < itemB.ItemName end, ByQuantity = function(itemA, itemB) return (itemA.Quantity or 1) > (itemB.Quantity or 1) end, ByRarity = function(itemA, itemB, ascending) local rarityA = itemA.Rarity or 0 local rarityB = itemB.Rarity or 0 if ascending then return rarityA < rarityB else return rarityA > rarityB end end }) -- Sort inventory (pushes empty slots to end) InventoryMaker.Sort("ByName") InventoryMaker.Sort("ByRarity", false) -- Descending order ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.