Iphone 3gs centre button not working on pressing hard?

P.s It works sometimes on pressing too hard.

Its broken and old

Needs replacing besides its an old device now. I would suggest taking it to a shop if you don't know how to fix it but its always cheaper if you do it yourself. I can assure you can find tons of videos on how to do it and the parts are usually $5 to $15. At a shop you might pay about $90 or something along those lines.

How to fix it?

Seriously, get a new one.