Here's a breakdown:
When to use a comma before "but":
* When "but" connects two independent clauses. An independent clause is a group of words with a subject and a verb that can stand alone as a complete sentence.
* Example: "The sun was shining, but the wind was cold."
When not to use a comma before "but":
* When "but" connects two phrases or clauses that are not independent.
* Example: "I was excited to go, but I couldn't find my keys." (The second part is not a complete sentence on its own.)
* When "but" introduces a contrasting element within a single clause.
* Example: "I like the color blue, but not the shade of blue on your shirt."
In short:
* Think about whether the part after "but" could stand alone as a sentence. If yes, use a comma. If no, don't use a comma.
Let me know if you'd like to see more examples!