Read this [How-to] Adapt your script to OneSync and fix your issues