Q: Changing object references in lua Here I generate a 4 x 8 panel with images and I save the reference into block.
local function createBlocks()

local rowcount = 8
    local colcount = 4

    local blockWidth = display.contentWidth / (colcount*4)
    local blockHeight = display.contentWidth / (rowcount*2)

    local row
    local col
    local pan = 3
    local i=0
    for row = 1, rowcount do
            for col = 1, colcount do
                    local x = (col - 1) * blockWidth + pan
                    local y = (row + 1) * blockHeight + pan
                    local random= math.random(1,6)

                    random = revisarTres(i, random)

                    print (random)
                    block[i] = display.newImage(images[random], x, y)
                    block[i].value= random     
                    block[i]:addEventListener("touch", blockTouch)
                    i=i+1
            end
    end

end
Then I add an event listener, to see if they have touched the image.
Then I validate that if they have made a touch, it  made the transition here.
transition.to(startBlock, {time=tranTime, x=event.target.x, y=event.target.y})
transition.to(event.target, {time=tranTime, x=startBlock.x, y=startBlock.y})

But I want to update this change in the block array. So I made this:
aux = block[old]
            auxval = block[old].value
            block[old]= block[new]
            block[old].value= block[new].value
            block[new]= block[old]
            block[new].value= auxval

but it isn`t working, I want to know a way to change the reference value.
I hope you can save me, please.

A: I want to say your exchange two value's function is wrong, see:
aux = block[old]
auxval = block[old].value
block[old]= block[new]
block[old].value= block[new].value
block[new]= block[old]
block[new].value= auxval

that's ugly,if you want to exchange block[old] and block[new],just like that:
block[old], block[new] = block[new], block[old]

