RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a inventory system with gui and drop function"
-- script for inventory system local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") local ScreenGui = Instance.new("ScreenGui") local Frame = Instance.new("Frame") local TextLabel = Instance.new("TextLabel") local TextButton = Instance.new("TextButton") local inventory = {} ScreenGui.Parent = PlayerGui Frame.Parent = ScreenGui TextLabel.Parent = Frame TextButton.Parent = Frame TextLabel.Text = "Inventory" TextButton.Text = "Drop Item" local function updateInventory() TextLabel.Text = "Inventory: " for i, v in pairs(inventory) do TextLabel.Text = TextLabel.Text .. v .. ", " end end local function dropItem() if #inventory > 0 then local droppedItem = table.remove(inventory, #inventory) TextLabel.Text = "Dropped: " .. droppedItem updateInventory() else TextLabel.Text = "Inventory is empty" end end TextButton.MouseButton1Click:Connect(dropItem) -- This is a basic inventory system with a drop function. You can add items to the inventory by adding them to the 'inventory' table. For example, to add an item called 'Sword', you would do 'table.insert(inventory, "Sword")'. This would add the Sword to the inventory and update the GUI. When the 'Drop Item' button is clicked, it removes the last item added to the inventory and updates the GUI.