How to Convert My GUI to a Script?

The general scripting term is serializing converting instance objects to script by only recording the data of which properties to change/are unique.

There is also this plugin which does it for you if you pay but there is a demo version.

Otherwise

Serializing resource:

General tutorial on serializing