Hi, good question!
I'll try to explain about the basic grammar.
に is used for the dirrection for places, for the purpose, for the indirect object
Ex.) わたしはこうえんにいきます。(I go to the park.)
わたしはさんぽにいきます。(I go to take a walk.)
わたしはあなたにほんをあげます。(I give you the book.)
を is used for the direct object.
Ex.) わたしはにほんごをべんきょうします。(I study Japanese.)
わたしはほんをよみます。(I read the book.)
わたしはえいがをみます。(I watch the movie.)
I hope this was helpful. To other Japanese people or advanced learners, please explain more if you can!