First step would be to Restart iPhone. Hold Top/Power button until Slide to Power Off come up and Turn iPhone OFF. The press Top/Power button to turn iPhone back ON. See if the Home button works.
Another thing to try is a Restore of Firmware with iTunes. See if the Home button works.
If not, there are so many reasons for a 3GS Home button to not function. Most of them are Hardware failure of the Home Button Flex Cable. The only way to check these is basically to open the iPhone and troubleshoot the Home Button Flex Cable, ie Flex Pad failure, copper contacts failure etc.
Does your iPhone still charge? Does your iPhone still connect to iTunes? If not, then you can take your iPhone to Apple Store and ask Genius to reseat Flex Cable #4 to the Logic Board. Make sure the iPhone is OFF before it is opened or damage can occur to Logic Board or LCD.
Can you still perform a Hard Reset of the iPhone. If yes, then the Home Button is fine and, then you can take your iPhone to Apple Store and ask Genius to reseat Flex Cable #4 to the Logic Board. Make sure the iPhone is OFF before it is opened or damage can occur to Logic Board or LCD.