Make sure your GameObject.FindWithTag(“Score”); finds the GUItext, otherwise it will return null and won’t set anything. you can check it with if(varText == null)
Alternatively, you can set your var to be a GUIText so that you can set it with targetText.text = name;
In the least, you can make it public and attach the GUIText object from hierarchy window to your script. But in order to do that, you should make your variable public.