first of all you need to look into expressions. Expressions are mathematically set of rules you define for how you want objects to behave.
take a look at those in the manuals before going any further!
Good luck ..
Senior 3D Artist,
Maya Software Manager & Maya Instructor
LEGO Systems A/S