How to delay something?

preserve the value of x before it is set again.

local x = 5
local y = x

delay(2, function()
    print(y * 2)
end)

x = 12

Not sure why you are doing this. Also I suggest using coroutine or or something else instead of delay as suggested by @Interaxis.