To create two folders in the attachments tab of a record via scripting when the record is created, you can use a script triggered by a record creation event. In the script, use the API to create two folders within the record's attachment tab, specifying their names and locations.