I don't think we can fix this. To support recursive functions, local variables have a separate value inside triggers. So in 'On start of layout' you actually assign to a separate value reserved for that trigger. When the 'On start of layout' event ends, the local variable reverts to its default value. Then after the 'Wait' action, since you're no longer in the trigger, the local value has lost its value that was set in the trigger.
I can't think how to fix this without breaking recursive functions. Can you work around by making the local variable static?