Gradually scale platform?

I want to have a platform that begins to scale to (about) 0 in width and length once the player walks on top of it, but I want the player to have enough time to walk past this platform before it shrinks completely.

Ignoring the code for the trigger event, how would I gradually scale this platform over some time interval t?

var startScale =;
var endScale =;
var t = 0.0;
var speed = .5;
while (t < 1.0) {
    t += Time.deltaTime * speed;
    transform.localScale = Vector3.Lerp(startScale, endScale, t);


Please: Why does my instanced prefab appear with my final scale and doesn’t do gradually?. I can’t write the yield instruction because I’m in an Update function, maybe this is the problem…What would you do with it?. Thanks in adavance.