Everyone is welcome to attend Mass, but receiving Communion has particular requirements. Catholics should be properly prepared and not conscious of unconfessed grave sin; Eucharistic fasting also applies.

A little more context

Christians not in full communion with the Catholic Church ordinarily do not receive, although Church law provides limited exceptions. If your circumstances are uncertain, ask a priest before Mass. You may remain in your place and pray during Communion; you do not have to join the procession.

A practical beginning

Before a first visit or a return after years away, contact the parish and explain your situation privately. Avoid making the decision solely by watching what the person next to you does.

Source & further reading

Catechism 1385–1401: preparation and Eucharistic communion (opens in a new tab)

Teaching summaries are introductions. Follow the linked Church source for its fuller context.