local player = game.Players.LocalPlayer local backpack = player:WaitForChild("Backpack") -- Create Inventory Count GUI local screenGui = Instance.new("ScreenGui") screenGui.Parent = player:WaitForChild("PlayerGui") local frame = Instance.new("Frame") frame.Size = UDim2.new(0.25, 0, 0.12, 0) frame.Position = UDim2.new(0.05, 0, 0.5, 0) -- Adjust position as needed frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) frame.BackgroundTransparency = 0.3 frame.Active = true frame.Draggable = true -- Make it moveable frame.Parent = screenGui local itemText = Instance.new("TextLabel") itemText.Size = UDim2.new(1, 0, 0.6, 0) itemText.Position = UDim2.new(0, 0, 0, 0) itemText.BackgroundColor3 = Color3.fromRGB(0, 0, 0) itemText.TextColor3 = Color3.fromRGB(255, 255, 255) itemText.TextScaled = true itemText.Text = "Inventory Items: 0" itemText.Parent = frame -- Create Show Button local showButton = Instance.new("TextButton") showButton.Size = UDim2.new(0.5, 0, 0.4, 0) showButton.Position = UDim2.new(0, 0, 0.6, 0) showButton.BackgroundColor3 = Color3.fromRGB(50, 255, 50) showButton.TextColor3 = Color3.fromRGB(255, 255, 255) showButton.TextScaled = true showButton.Text = "Show" showButton.Parent = frame -- Create Hide Button local hideButton = Instance.new("TextButton") hideButton.Size = UDim2.new(0.5, 0, 0.4, 0) hideButton.Position = UDim2.new(0.5, 0, 0.6, 0) hideButton.BackgroundColor3 = Color3.fromRGB(255, 50, 50) hideButton.TextColor3 = Color3.fromRGB(255, 255, 255) hideButton.TextScaled = true hideButton.Text = "Hide" hideButton.Parent = frame local isInventoryVisible = false -- Function to count inventory items local function updateInventoryCount() local itemCount = #backpack:GetChildren() local character = player.Character if character then for _, tool in pairs(character:GetChildren()) do if tool:IsA("Tool") then itemCount = itemCount + 1 end end end itemText.Text = "Inventory Items: " .. itemCount end -- Show Button Function showButton.MouseButton1Click:Connect(function() isInventoryVisible = true itemText.Visible = true updateInventoryCount() end) -- Hide Button Function hideButton.MouseButton1Click:Connect(function() isInventoryVisible = false itemText.Visible = false end) -- Update inventory when items are added or removed backpack.ChildAdded:Connect(updateInventoryCount) backpack.ChildRemoved:Connect(updateInventoryCount) -- Update inventory when the player dies (resets items) player.CharacterAdded:Connect(function() wait(1) -- Small delay to let items reset updateInventoryCount() end) -- Initial update updateInventoryCount()