Help lua code - lua table support

Hello guys! How can I make it appear green if position one of my table is empty and if there is one in position 1 it is red?

image

-- Declared

local obj_1 = script.Parent["1"]

local obj_2 = script.Parent["2"]

local obj_3 = script.Parent["3"]

-- Inventory Array

local inventory = {}

-- Adding inventory test

table.insert(inventory,1,obj_1)

if #inventory >= 1 and #inventory <= 3 then

print("There are ".. inventory) --example

end

In short, I need to make the list the boxes in the image and the objects that I add to my table occupy the boxes in the inventory, how could i do that?

Simply put that in a loop like that :

for _, v in pairs(script.Parent:GetChildren()) do
   if inventory[v.Name] then
        v.BackgroundColor3 = Color3.fromRGB(20, 225, 0)
   else
        v.BackgroundColor3 = Color.fromRGB(25, 25, 25)
   end
end