Hi @Jay ,
To use a variable in a script, first ensure that the variable has been added to either the list contained in the ReadOnlyVariables property or the list contained in the ReadWriteVariables property of this script task, according to whether or not your code needs to write to the variable.
You may refer to how-to-access-ssis-package-variables-inside-script-component and ssis-write-to-object-variable-through-script-task for detail information.
Regards,
Zoe Hui
If the answer is helpful, please click "Accept Answer" and upvote it.