You have to write codes to access the variables in these two components in a slight different way.
For Script Task:
DTS.Variables[“VariableName”].Value
For Script Component:
Variables.VariableName
Don’t forget to add these variables in task editor first. š