Parenting, Changing variables of parent objects, and how to make those variables effect child objects

Okay, editting this for clarity

I need to know 3 things.

1) How to change a variable found in a parent object using a ray caster. 2) How to parent one gameobject to another game object (say, 1 cube to another cube) 3) How to make it so that the variable changed within the parent object, causes something to happen to the child object.

Specifically. I want to hit the parent object with a raycaster when I hit the correct button. Once hit, it will change a variable within that parent object between two states (1 and 2). In the first state, the child object will be visible, in the second state, the child object should be invisible.

Any suggestions on how to get this done?

gameObject.renderer.enabled - I think this should help you get started.

1) How to change a variable found in a parent object using a ray caster. once you have the GameObject found from the ray cast you can get the correct component of the object and modify it.

Foo fooParent = hitObject.GetComponent<Foo>();
fooParent.PropertyToChange = newValue;

2) How to parent one gameobject to another game object (say, 1 cube to another cube)

transform.parent = otherObject.transform;

3) How to make it so that the variable changed within the parent object, causes something to happen to the child object. In your example above you could get an object in the children object by doing something like this use the above code to get the object fooParent then

FooChild fooChild = fooParent.GetComponentInChildren<FooChild>();
fooChild.renderer.enabled = value;