All Instances are Folders, ValueBases, and a few other similar types. This is bad for a few reasons.
Example 1:
if (myInstance.IsA("Folder")) {
// Do something with folders
} else if (myInstance.IsA("Part"))
// Do something with parts
}
Example 1 will error on calling "IsA" in the else if clause, since it is of type "never" after it has been determined not to be a Folder (and since all Instances are Folders, it must not be an instance)
Example 2:
if (myInstance.IsA("Part")) {
// Do something with parts
} else if (myInstance.IsA("Folder"))
// Do something with folders
}
Example 2 works as a workaround for this issue in this case—however, this does not work if you have an "else" clause at the end, or are dealing with multiple all-encompassing types (like ValueBase with Folder)
Example 3:
if (myInstance.IsA("Folder")) {
// Do something with folders
} else {
print("Found another instance of type" + myInstance.ClassName)
}
Since all Instances are Folders, the example 3 will error, because "myInstance" is of type "never" in the else clause.
To work around this, you must use a type assertion (myInstance as Instance), or something similar, in clauses following all-encompassing type guards
Right now I have some pretty ugly code