Greetings of peace,
According to the Islamic belief, acts of worship should be done with the correct theological beliefs and understanding. One cannot know and truly understand how to worship God without going to the prophets, messengers and holy people that He sent to convey His message.
The Quran states:
“إِنَّ الدِّينَ عِندَ اللَّهِ الْإِسْلَامُ
Truly, the religion with Allah is Islam.”
It is however possible that some non-Muslims will be excused for not being able to find or ascertain the truth.
In Islam we also believe acts of goodness do not go unnoticed regardless of the person’s religion. But for acts of worship, these cannot be made up and must be done in the correct way.
May Allah guide you and all of us to that which is the truth.