First, please don't misled by the name, this is a script that can copy a whole folder into another folder, includes team drive. That is because team drive is also a folder, it has a folder id in the URL.
URL is looks like this: https://drive.google.com/drive/folders/SfylswnasvBdCgyIOsF7 (it's fake.) If you are confusing about what is a folder id, in this example, "SfylswnasvBdCgyIOsF7" is the folder id, it can be shorts, or it can be very very long and complex.
Please notice that this script does not check whether you have permission to access and manage target folder or not.