The thing with melatonin is your body produces it naturally. It's almost always marketed as a "sleep aid" because it's a non-prescription "supplement", and not guaranteed to work.
If taking melatonin (especially large doses) doesn't work, consider talking to your doctor about sleep issues. There may be something else preventing proper sleep.