You should be careful when choosing friends.

Literal

Friend [object-を] choose occasion [at-には] care [object-を] attach [should-べきだ].

際 (さい) is a formal synonym of とき ('time, occasion'), giving the sentence a slightly elevated register. 気を付ける (literally 'attach care') is the standard idiom for being careful. べきだ adds moral obligation — 'one ought to.'