The script below is supposed to be for an Inventory GUI. When an item lands in a folder, the folder's script, which is shown below, moves it to an available spot. However, I plan to add more than just 3 rows to the inventory, which would make this script incredibly long, and I can't help but think there's a more efficient way to type all of this. Is there a way?
script.Parent.ChildAdded:connect(function(item) local checkInfo = item:FindFirstChild("Info") --Checks to see if it is a proper item. if checkInfo ~= nil then local body = script.Parent.Parent.Frame local r1 = body.Row1 --The rows are just rows in the inventory; they each contain boxes for the item called slots. local r2 = body.Row2 local r3 = body.Row3 if r1.Occupied.Value ~= true then if r1.T1.Occupied.Value ~= true then item.Parent = r1.T1.Item elseif r1.T1.Occupied.Value == true and r1.T2.Occupied.Value ~= true then item.Parent = r1.T2.Item elseif r1.T1.Occupied.Value == true and r1.T2.Occupied.Value == true and r1.T3.Occupied.Value ~= true then item.Parent = r1.T3.Item end elseif r1.Occupied.Value == true and r2.Occupied.Value ~= true then if r2.T1.Occupied.Value ~= true then item.Parent = r2.T1.Item elseif r2.T1.Occupied.Value == true and r2.T2.Occupied.Value ~= true then item.Parent = r2.T2.Item elseif r2.T1.Occupied.Value == true and r2.T2.Occupied.Value == true and r2.T3.Occupied.Value ~= true then item.Parent = r2.T3.Item end elseif r1.Occupied.Value == true and r2.Occupied.Value == true and r3.Occupied.Value ~= true then if r3.T1.Occupied.Value ~= true then item.Parent = r3.T1.Item elseif r3.T1.Occupied.Value == true and r3.T2.Occupied.Value ~= true then item.Parent = r2.T2.Item elseif r3.T1.Occupied.Value == true and r3.T2.Occupied.Value == true and r3.T3.Occupied.Value ~= true then item.Parent = r3.T3.Item end elseif r1.Occupied.Value == true and r2.Occupied.Value == true and r3.Occupied.Value == true then print("no room") item:Destroy() end end end)