I came across this sentence while I was learning how to use the vocabulary word 一生:
先生は彼に英語を一生懸命に勉強するようにと言いました。(The teacher told him to study English hard.)
I couldn’t understand what is the purpose of に in this part: 一生懸命に勉強する. I believe the word 一生懸命 is used as an adverb here, which would mean that the word is affecting the verb 勉強する, but I can’t see the connection with the particle in between. Thanks in advance!

