Is it okay to take a melatonin when your heart beats rapidly?

Likely it won’t hurt but there are better solutions. When your heart beats fast first slow down or stop what you are doing. Second you should have a drink of water, this can sometime help to stop the fast heartbeat. If it still continues you should see your physician.