A sentence has a telling part. Sometimes a sentence has two telling parts with different or opposite ideas.
These telling parts can be joind with the word but.
A comma (,) is usually used before the word but.
This monkey likes to swing, but doesn't like to swim.
We can be happy, but our friends can be sad.
The boys are hungry, but they are also sleepy.