When you join two independent clauses (complete sentences) with a coordinating conjunction (and, but, or, nor, for, so, yet—also known as the FANBOYS), you must place a comma before the coordinating conjunction.
The rule is very clear, here. The comma before the coordinating conjunction works with the coordinating conjunction to help make a proper boundary between the two independent clauses.
In this example, the sentence is missing the comma before the but because the but joins two complete thoughts. Leaving out this necessary comma creates an error because you have two sentences connected without a proper boundary between those sentences.
Here is a correction for the sentence:
For more information on this comma rule, be sure to check out the Comma section in the Punctuation area of Grammar Essentials.