local function o()local o=iContainer.UIGridLayout local A=iContainer:GetChildren()local P=o.FillDirectionMaxCells local c=math.ceil((#A-1)/P)local G=(o.CellSize.Y.Offset+o.CellPadding.Y.Offset*2)*c iContainer.Size=UDim2.new(.8,0,0,G)mFrame.CanvasSize=UDim2.new(0,mFrame.CanvasSize.X.Offset,0,iContainer.Size.Y.Offset+100)local T={}for o,A in pairs(char:GetChildren())do if A:IsA("\084\111\111\108")then currentTool=A table.insert(T,A)end end for o,A in pairs(plr.Backpack:GetChildren())do if A:IsA("\084\111\111\108")then table.insert(T,A)end end print(#T)if#T>1 then local o=T[1]local A=game.ReplicatedStorage.Prefabs local P=A.ItemSlot local c=P:Clone()c.Parent=iContainer c.equip.Text=o.Name c.ItemName.Value=o.Name o:Destroy()end table.clear(T)end
-- Functions

local function onRenderStepped()
	-- Adjust main frame canvas size based on amount of items.

	local uiGridLayout = iContainer.UIGridLayout
	local containerChildren = iContainer:GetChildren()

	local maxRowItems = uiGridLayout.FillDirectionMaxCells
	local rowCount = math.ceil((#containerChildren - 1) / maxRowItems)

	local totalHeight = (uiGridLayout.CellSize.Y.Offset + (uiGridLayout.CellPadding.Y.Offset * 2)) * rowCount

	iContainer.Size = UDim2.new(0.8, 0, 0, totalHeight)

	mFrame.CanvasSize = UDim2.new(0, mFrame.CanvasSize.X.Offset, 0, iContainer.Size.Y.Offset + 100)

	-- Get amount of tools player owns

	local toolsFound = {}

	for i, obj in pairs(char:GetChildren()) do
		if obj:IsA("Tool") then
			currentTool = obj
			table.insert(toolsFound, obj)
		end
	end

	for i, obj in pairs(plr.Backpack:GetChildren()) do
		if obj:IsA("Tool") then
			table.insert(toolsFound, obj)
		end
	end

	print(#toolsFound)

	-- If player has more than 1 tool in his character. . .

	if #toolsFound > 1 then
		-- Transport second item to inventory storage

		local toolToTransfer = toolsFound[1]

		local folder_prefabs = game.ReplicatedStorage.Prefabs
		local prefab_itemSlot = folder_prefabs.ItemSlot

		local itemSlot = prefab_itemSlot:Clone()
		itemSlot.Parent = iContainer

		itemSlot.equip.Text = toolToTransfer.Name

		itemSlot.ItemName.Value = toolToTransfer.Name

		-- Remove tool from existence

		toolToTransfer:Destroy()
	end

	-- Reset table

	table.clear(toolsFound)
end
