Hey Dan, thank you so much for your answer. Yes, I have noticed that after effects start to act strange when I use global $. I have managed now to reference it directly to text length.
v = thisComp.layer("Text").text.sourceText.length;
if (v<5) {100} else {0}