In the ON and OFF script of a unit a call to the value verb will return the current value of the unit, not the new value being set. In order to see what the future value of the unit will be you need to use the Future Value verb.
future value
returns a real number that will be the value of unit after the new command is received.
see also: change future value