Chosen Solution

I don’t know how it happened but the speaker only works when a certain part of the logic board is pressed

What part of the logic board is it? if it is near the display connectors, it is a problem with the audio codec and that would need to be reballed. If it is near the lightning connector, just reseat it or replace it and it should be fine.