Sacred Citation & SourceThe Prophet ﷺ said: "Actions are judged by intentions, and everyone will have what he intended" (Bukhari 1, Muslim 1907). The same act, such as giving money or learning, can be a great act of worship or worth nothing, depending on why it is done.
Sacred Citation & SourceAllah says: "They were commanded only to worship Allah, sincere to Him in religion" (98:5). Sincerity (ikhlas) means doing a good act for Allah alone. Its opposite, riya, is doing it to be seen and praised. Allah says in a divine hadith: "I am the most self-sufficient of partners; whoever does an act in which he associates someone with Me, I leave him and his act" (Muslim 2985).
Practical ideas: renew your intention before each act, do some good in secret, and do not give up a good act for fear of being seen (that too is a trap). Ask Allah for sincerity. These are matters of the heart, not of rulings: take what helps you act and ask a qualified teacher if you are unsure.