How can I do this?

function fridge()
        local food = {}
        food[1] = "models/props_junk/garbage_milkcarton002a.mdl"
	food[2] = "models/props_junk/PopCan01a.mdl"
	food[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
	food[4] = "models/props_junk/watermelon01.mdl"
	food[5] = "models/props_junk/garbage_metalcan001a.mdl"
	food[6] = "models/props_lab/box01a.mdl"
	food[7] = "models/props_lab/box01b.mdl"
        local frame = vgui.Create("DFrame")
	local IconList = vgui.Create( "DPanelList", frame ) 
 	IconList:EnableVerticalScrollbar( true ) 
 	IconList:EnableHorizontal( true ) 
 	IconList:SetPadding( 4 ) 
	IconList:SetSize(200, 160)
	for k,v in pairs(food) do
	local icon = vgui.Create( "SpawnIcon", IconList ) 
	icon:SetModel( v )
 	IconList:AddItem( icon )
	icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end 

How can I make it spawn an entity somehting or give you a weapon if you hit the first button? Then something different by hitting the 2nd button etc?

make the user send an console command, then handle the entity creation and the weapon giving server side ^^

Cant you just do somehting like

if selection or w/e is == food[1] then


or somehting along those lines

So if you have food give them an AK47?

That makes sense.

Do what bromvlieg says. If you’re unsure on how you need to study lua more from the wiki.

Forget about what the icons are. I just wan to know how to make it so if you press the first button is spawns a specific entity, then if you hit the 2nd button it spawns different entity and so on and so forth.

Bromvlieg just told you. Make a console command server side which takes in an argument of what type of entity you want and it spawns it.

When they press the button, call the command and pass through the right parameters.