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


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
