But and however are often used interchangeably to mean ‘yet’, but they are punctuated differently because however in this context is a conjunctive adverb.
Jim lost a fortune gambling, but he still lives in a mansion.
Jim lost a fortune gambling; however, he still lives in a mansion.
or
Jim lost a fortune gambling. However, he still lives in a mansion.
But is often regarded as more informal than however.
But and however have some distinct meanings.
But means ‘on the contrary’ and ‘with the exception that’.
I like everyone but her.
However can also be used to mean ‘by whatever means, condition or state’.
I will get there however I can.
The word ‘but’ can be used in the sense of ‘although’.
We waited for him for a long time, but he did not turn up.
The word ‘however’ can be used in the sense of ‘nevertheless’.
The test match, however, continued despite protests from both the teams.
Some people think you can’t use but at the beginning of a sentence.