There's a system to do omething like this called Prim Puppeteer:
https://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=163930That's a link to the free version, which I believe is full-featured but not transferrable. If it works for you and you want to make it distributable, just buy the full version.
If you really want to learn scripting rather than simply building your transformer, post again in your "scripting tips" thread and state that you know about puppeteer, but are interested in learning how to write a script to do this yourself.
It may be a bit advanced for someone's first script, though. But with a goal in mind we might be able to walk you through a few simpler scripts in preparation.
I'd stick with puppeteer, and save learning your own scripting for when you want to add other (simple) features to your transformer.
There may be good competition to Prim Puppeteer, but it's the industry leader for this purpose. I haven't used it myself, but I've seen a number of good products made with it. I have written scripts that do similar things (with objects, though, not prims).
Someone with Puppeteer experience can say whether you can make it flip states on touch. In the products I've seen, it keeps repeating the sequence of motions. But I bet it has other options.
Note that it can animate a whole sequence, so you can show the transformer unfolding, rather than just zipping to the new shape (if you want).