Here's the rule:
* Independent clause + , + but + independent clause
Example:
* I wanted to go to the beach, but it was raining.
Explanation:
* "I wanted to go to the beach" is a complete sentence (an independent clause).
* "It was raining" is also a complete sentence (another independent clause).
* "But" connects these two independent clauses.
When you don't need a comma:
* Dependent clause + but + independent clause
Example:
* Although I wanted to go to the beach, but it was raining.
Explanation:
* "Although I wanted to go to the beach" is a dependent clause (it can't stand alone as a sentence).
* "It was raining" is an independent clause.
* You don't need a comma before "but" because it's connecting a dependent clause to an independent clause.
Let me know if you have any other grammar questions!