The best way to do this is directly through code and not through RunScript. Here’s some sample python code that should help to get you started
RunScript