Your second attempt only needs one more fact: $(A \cup B)' = A' \cup B'$.
To see this: pick $x \in A'$. Then every neighbourhood $U$ of $x$ intersects $A$ in at least one point different from $x$. This point is also in $A \cup B$, so then every neighbourhood of $x$ intersects a point of $A \cup B$ not equal to $x$, so $x \in (A\cup B)'$. Similarly, if $x \in B'$, $x \in (A \cup B)'$, so we have $A' \cup B' \subset (A \cup B)'$.
On the other hand, if $x \in (A \cup B)'$, we need to show $x$ is in $A' \cup B'$. So assume not, $x \notin A'$, which means there is a neighbourhood $U$ of $x$ that intersects $A$ in an empty set or just $\{x\}$. Also $x \notin B'$, so there is a neighbourhood $V$ of $x$ such that $V$ intersects $B$ either in the empty set or $\{x\}$. Now, $U \cap V$ is a neighbourhood of $x$, and $(U \cap V) \cap (A \cup B) = (U \cap V \cap A) \cup (U \cap B \cap V) \subset (U \cap A) \cup (V \cap B)$, which is also either the empty set or $\{x\}$, from the properties of $U$ and $V$. But this contradicts that $x \in (A \cup B)'$. So our assumption was incorrect: $x$ must be in $A' \cup B'$, as required.