Stuck with program flow and freezing programm

When you convert bits of duplicated code to a function, you might need to pay attention to what variables the function is modifying.

How do you mean? Do I have to change variables from global to local var's or is there any rule what to be changed?