attack button doesn't work when joystick is pressed

If i am moving my character with the virtual joystick the attack button doesn’t work until i leave my finger from the joystick

you should try

if (Input.touchCount > 0) {
Touch touch = Input.GetTouch (0);

if (touch.phase == TouchPhase.Began) { Do some shit
}

if (touch.phase == TouchPhase.Began && input.touchCount > 1) {
// will probably solve your probleme

		}

How did you implement your joystick and does your device support multitouch?