Please read the training articles on our Parrot Training page for help with this issue.
Basically, you will need to spend time with the bird and learn it's body language so you can respect when it does not like something and gain it's trust. Developing a good relationship is the beginning point for training the bird to replace a bad behavior with another behavior you want.