How to make something move over if an item is in a slot

This is the concept you should be using:

for i = 1, #invSlots do
    if not invSlots[i].Value then -- check that the slot's item doesn't exist
        invSlots[i].Value = item
        break
    end
end

Clearly you should be fixing it to match your game/code structure.

Edit: Samjay’s code serves a different purpose than this one, and honestly, the code that I’ve provided shouldn’t even be necessary unless you have some edge-case.