The most likely reason is a path issue.

Make sure the actions are on Frame 1 and cover all frames on the root timeline.
This will make sure the same var is used across all the frames.
Also when assigning a type to a var don't use . even though the syntax will pick up the word text it will still think its a paths
so txt.text = ""; is not the same as txt = "";

Without see any code it would be hard to say for sure though its the most likely cause to your issue.