You're right. The use of "nya" is quite confusing for people who are learning Indonesian as this word is used not only to express one meaning.
Basically, the use of -nya is for third person. (already answered before)
Ayah saya sangat baik. Saya sangat sayang padanya. (My father is so kind. I love him so much)
Another is like the one that has been mentioned before.
-Nya for specific things. Just like the use of "the" in English
But actually this is very informal, sometimes it's considered wrong. I don't suggest this for formal writing.
There are also several uses of -nya that are used in informal way. One of them is when Indonesian people use -nya instead of -mu to show a certain degree of politeness
This is an example:
A woman on the street dropped her wallet. You saw it (you barely know this woman) and tell her:
- Mbak, pulpennya jatuh -
See, "pulpennya" actually means: "pulpenmu". But it is so common that Indonesian people say -nya to replace -mu just simply to make it a little bit more polite.
Other use is for some certain words like:
Nyata / Fakta - Nyatanya / Faktanya
Translation in English: Nyata = real (Adjective), Fakta = Fact (Noun)
Nyatanya = Ternyata / Faktanya= (It turned out that..../ The fact is...)
Another example in this case:
"Kelihatannya/sepertinya/kayaknya (informal) akan turun hujan = It seems that it will be raining."
Kelihatannya/sepertinya can mean: "It seems / it seems like" or sometimes can mean "it looks/ it looks like".
Seharusnya/harusnya (shortened)= Should.
The meaning and the function is the same with when we use "should" in English, which is to say suggestion or something that you should've done but you didn't.
"Saya lapar. Saya seharusnya makan siang dulu" (I am starving. I should have had lunch first.)
For this case, it is common to use them both in formal writing and daily conversation.
Hope this will help you to understand more about Bahasa :)