investing in nifty or sensex

how should i invest in sensex or nifty because most experts say invest in in nifty or sensex for 30 years and you will have great returns?

The best way is to buy index exchange traded funds (ETF). Niftybees is for Nifty and SBISENSEX for Sensex. You can buy this similar to how you buy stocks.

You can learn more about ETFs here