Accessing variables from other scripts.

Hi, I don’t know what I am doing wrong. All i want to do is use a variable from another script from the parent of the object.
i have seen this:
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
but it still doesn’t help me.

var parentScript : AmmoShop;
parentScript = transform.parent.GetComponent(AmmoShop);

print(parentScript.mgAmmo);

Explain what the problem actually is, please (in detail).

–Eric