N4
ように
So that, In order to, In such a way that
お母さんから離れないように手をつなぐ。
I hold my mother's hand so that I won't get separated from her.
Explanation
「ように」 means 'so that' or 'in order to'. The first part is the state you want to bring about, and the second is what you do for it. Before it you normally find:
A potential form: 「日本語が話せるように、毎日練習する」 (I practice every day so that I can speak Japanese).
A verb outside your will: 「風邪が治るように、薬を飲む」 (I take medicine so that my cold goes away).
A negative: 「忘れないようにメモする」 (I take notes so as not to forget).
The subjects of the two parts can be the same or different: 「子供が野菜を食べるように、細かく切る」.
Mixed up with
Versus 「ために」: 「ために」 follows the dictionary form of a volitional verb and needs the same subject in both parts: 「留学するために、貯金する」. 「ように」 follows a potential, non-volitional or negative form and aims at making a state come true: 「留学できるように、日本語を勉強する」.
'So as not to' is usually 「〜ないように」: 「遅れないように」. 「〜ないために」 also exists but is more deliberate and written (「太らないために運動する」).
When the subjects differ, only 「ように」 works: 「親が喜ぶように、頑張る」.