I walk on Shabbat and I see a baby crawling in danger, I pick up the baby and give it to the mother. She slips something in my pocket and the better of me goes to see what in my pocket and I pull out a 100 dollar bill, did I brake Shabbat law.
Picking up the baby was a very important act to do. However walking to give the baby to his mother, would consist of carrying on shabbos, if there is no eruv there, and should not be done.
Regarding the money that the mother slipped you, the money is muktza on shabbos and it should not have been pulled out of your pocket. Although on the other hand, even without pulling the money out of your pocket you are now in a tough position, because we are not allowed to carry anything in our pockets, if there is no eruv there.