Check the touch screen connector on the logic board. It's the wide horizontal one below the rear camera on the logic board.
Could be dirty, physically damaged or worn out.
Also check for signs of liquid damage. The are various LCI (Liquid damage indicator) stickers placed on the logic board.
One at top of board another behind screen assembly back metal plate.
They are initially coloured white to mean it has not been in contact with liquid / moisture.
Once it's red it means it has been in contact with moisture.