Issue with implementing tool order

so im trying to implement tool order, and i get really weird results:

for i, tool in ipairs(player.Backpack:GetChildren()) do
	local button = template.ImageButton:Clone()
	button.Parent = frame
	button.Name = tool.Name
	button.Image = tool.TextureId
	button.LayoutOrder = tool:GetAttribute("LayoutOrder")
	
	local number = tool:GetAttribute("LayoutOrder")
	
	table.insert(tools, number, tool)
	print(tools)
	
	button.MouseButton1Click:Connect(function()
		if tool then
			if tool.Parent ~= character then
				humanoid:EquipTool(tool)
			else
				humanoid:UnequipTools()
			end
		end
	end)
end

prints like this:

 ▼  {
                    [1] = "MP 43",
                    [2] = "Shovel",
                    [3] = nil,
                    [4] = "Panzerfaust",
                    [5] = "Panzerschreck"
                 }

panzerfaust is supposed to be [3] and panzerschreck is [4]
any idea how to fix this?

3 Likes