
89 P.3d 6 (2004)
2004 MT 97
Elmer L. COWAN, M. Pauline Cowan and Twila M. Smith, Plaintiffs and Appellants,
v.
Kathy C. COWAN, a/k/a Kathy Couchois and Dan and Kelley Floyd, Defendants and Respondents.
No. 03-164.
Supreme Court of Montana.
Submitted on Briefs July 10, 2003.
Decided April 20, 2004.
*7 For Appellants: G. Patrick Hagestad and Perry J. Schneider, Milodragovich, Dale, Steinbrenner & Binney, Missoula, Montana.
For Respondents: Evonne Smith Wells, Missoula, Montana (K.Cowan), David T. Markette, Hamilton, Montana (Floyds).
Justice W. WILLIAM LEAPHART delivered the Opinion of the Court.
¶ 1 The issue on appeal is whether the District Court's dismissal of the Cowans' and Twila's complaint was incorrect as a matter of law? We affirm.

Factual and Procedural Background
¶ 2 Elmer and Pauline Cowan (the Cowans) are the parents of Twila Smith (Twila) and Arden Cowan (Arden). Arden was married to Kathy Cowan (Kathy). Kathy and Arden separated in 2000 and eventually divorced after approximately eleven years of marriage. The Cowans contend that they transferred certain property to Kathy as trustee for the care of their son Arden who is disabled from polio. The District Court dismissed their complaint in which they challenged Kathy's ownership and proposed sale of the property to Dan and Kelley Floyd (the Floyds).
¶ 3 In the dissolution proceedings, the court (Judge Larson) awarded Kathy the land at issue, approximately 170 acres located in Ravalli County. Judge Larson decided that the parties' antenuptial agreement was not enforceable because there was no meeting of minds regarding what the agreement meant. Noting that Arden had attempted to insulate the property from the child support dispute he was having with his former wife by disclaiming any interest in the property, the court cited the equitable principle of unclean hands and the doctrine of judicial estoppel and concluded that he was estopped from subsequently claiming an interest in that same property. Kauffman-Harmon v. Kauffman, 2001 MT 238, 307 Mont. 45, 36 P.3d 408. Judge Larson observed that to give validity to such a scheme would violate the public policy of encouraging and facilitating child support payments. Since Arden's parents had gifted the property to Kathy during the marriage, the court awarded the property to Kathy.
¶ 4 Subsequent to the dissolution proceedings, the Cowans filed a complaint for declaratory relief, seeking to have the District Court determine the Cowans' and Twila's ownership rights in the property and whether an express, constructive, or resulting trust existed. They also requested a temporary restraining order prohibiting the sale of the property until the court issued a declaratory judgment. Attached to their complaint for declaratory relief were a warranty deed, a document describing the property, Kathy's will (dated March 9, 1991), a document Kathy signed granting Arden general power of attorney, a handwritten, undated document signed by the Cowans that stated the Cowans were transferring property to Kathy for Arden's support and maintenance, and the Findings of Fact and Conclusions of Law and Decree of Dissolution of Arden's and Kathy's marriage.
¶ 5 When Judge Larson did not act to prohibit the sale, the Floyds purchased the property from Kathy. The sale was completed, and the Floyds are now the record owners of the property. Kathy and the Floyds both moved to dismiss the Cowans' complaint for declaratory judgment and preliminary injunctive relief. The court (Judge McLean) granted the Floyds' motion to dismiss because they had purchased the property under the protection of a court order after this Court declined to issue a writ of supervisory control stopping the sale. The District Court also stated that the Cowans' and Twila's request for a temporary restraining order and preliminary injunction was moot because the sale to the Floyds was completed under Judge Larson's direction in the dissolution proceeding. Kathy's motion for dismissal was similarly granted because the court determined, based upon the complaint, *8 the answer, and the attached documents, that neither the Cowans nor Twila had any enforceable ownership interests in the property at issue.
¶ 6 The court examined the complaint and attached documents and determined that the deed to Kathy contained no restrictions or conditions granting Twila an ownership interest. Similarly, the court concluded that when the Cowans deeded the property to Kathy, they did not reserve any ownership interest to themselves. The court concluded that the Cowans and Twila had no enforceable legal ownership interests in their own right to the disputed property. Any rights that they arguably had were dependent upon Arden's equitable interest which was duly adjudicated in the dissolution action. The court noted that the property distribution in the dissolution proceeding could be challenged on appeal in that matter but could not "be relitigated in this action under the guise that the [Cowans and Twila] have separate and distinct legally enforceable ownership interests in the property." The court awarded the Floyds and Kathy statutory costs of suit and denied their request for attorneys' fees. We recently affirmed the order in the dissolution proceeding in Cowan v. Cowan, 2004 MT 68, 320 Mont. 332, 87 P.3d 443.
¶ 7 On appeal, the Cowans and Twila contend the court's dismissal of their complaint was incorrect as a matter of law. They claim to have alleged facts sufficient to support a finding that the Cowans were trustors of a trust created for Arden's benefit and that Twila is a successor trustee and/or beneficiary of the trust. They contend that, based on these alleged facts, they stated a claim for declaratory judgment as to the existence of a trust. They assert that their property interests are separate and distinct from Arden's rights in the property. They also point out that Arden is not a party to this current action.
¶ 8 The Cowans and Twila claim it was error for the District Court to make a factual determination that the handwritten document the Cowans executed was insufficient to create a legally enforceable ownership in the property. The Cowans and Twila allege that the court failed to apply the appropriate standard for reviewing a motion to dismiss because it did not take all factual allegations as true. They contend that if all their allegations are taken as true and all facts viewed in the light most favorable to them, they clearly set forth facts sufficient to establish that the property was held in trust and therefore the proceeds from the sale of the property should likewise be held in trust for Arden's benefit.

Discussion
¶ 9 Whether the District Court's dismissal of the Cowans' and Twila's complaint was incorrect as a matter of law?
¶ 10 We review a district court's ruling on a motion to dismiss pursuant to Rule 12(b)(6), M.R.Civ.P., de novo. Powell v. Salvation Army (1997), 287 Mont. 99, 102, 951 P.2d 1352, 1354. "This Court reviews an appeal from a district court's order granting a motion to dismiss based on the sufficiency of the complaint." Powell, 287 Mont. at 102, 951 P.2d at 1354 (citation omitted). The determination that a complaint fails to state a claim is a conclusion of law that we review to determine whether the court's interpretation of the law is correct. City of Cut Bank v. Tom Patrick Const., Inc., 1998 MT 219, ¶ 6, 290 Mont. 470, ¶ 6, 963 P.2d 1283, ¶ 6. We have previously stated that
[a] complaint should not be dismissed for failure to state a claim unless it appears beyond doubt that the plaintiff can prove no set of facts in support of his claim which would entitle him to relief. A motion to dismiss under Rule 12(b)(6), M.R.Civ.P., has the effect of admitting all well-pleaded allegations in the complaint. In considering the motion, the complaint is construed in the light most favorable to the plaintiff, and all allegations of fact contained therein are taken as true.
Powell, 287 Mont. at 102, 951 P.2d at 1354 (citation omitted).
¶ 11 The only relevant document when considering a motion to dismiss is the complaint and any documents it incorporates by reference. City of Cut Bank, ¶ 20. The mere fact that documents are attached to a complaint does not automatically require that *9 the motion to dismiss be converted into a Rule 56 motion for summary judgment. City of Cut Bank, ¶ 20. We have previously upheld a Rule 12(b)(6) motion to dismiss when the trial court based its decision upon a complaint and information contained in attached documents. City of Cut Bank, ¶ 20 (the court considered the complaint as well as the attached contract documents).
¶ 12 The Cowans allege that the District Court considered matters outside the pleadings and thus the court should have given notice to the parties that the motion was being converted to a Rule 56 motion for summary judgment with all sides afforded an opportunity to fully brief the issues as such.
¶ 13 We find no indication that the court considered matters outside the record. City of Cut Bank, ¶ 20. We accept at face value the court's order that it was ruling on motions to dismiss and that the court's order was based upon the allegations in the complaint and based on the information in the attached documents. City of Cut Bank, ¶ 20.
¶ 14 The Cowans allege if all facts they have alleged are taken as true, they clearly stated a claim entitling them to relief and the court erred in dismissing their complaint. However, the Cowans are incorrect as to what the court must take as true. Facts must be viewed in a light most favorable to the plaintiff, however, the court is under no duty to take as true legal conclusions or allegations that have no factual basis or are contrary to what has already been adjudicated. Powell, 287 Mont. at 102, 951 P.2d at 1354. In the dissolution matter, Judge Larson noted that Arden had repeatedly and previously testified that he had no interest in the properties; thus the court concluded that Arden's claim of a beneficial interest in the property via a constructive trust must fail as Arden had unclean hands and was barred by judicial estoppel.
¶ 15 "The fundamental purpose of judicial estoppel is to protect the integrity of the judicial system and thus to estop a party from playing `fast and loose' with the court system." Kauffman-Harmon v. Kauffman, 2001 MT 238, ¶ 15, 307 Mont. 45, ¶ 15, 36 P.3d 408, ¶ 15. "[T]he doctrine of judicial estoppel binds a party to his or her judicial declarations, and precludes a party from taking a position inconsistent with previously made declarations in a subsequent action or proceeding." Kauffman-Harmon, ¶ 15. In Kauffman-Harmon, we examined the doctrine of judicial estoppel as it applies to resulting and constructive trusts. In that case, we determined that when Dr. Kauffman claimed in a previous legal action that he had no interest in certain assets that he had transferred to a corporation, he was barred from claiming an interest in the assets in a subsequent proceeding. Kauffman-Harmon, ¶ 17.
¶ 16 The court also determined that the equitable doctrine of unclean hands barred Arden's interest in the property. This doctrine "provides that `parties must not expect relief in equity, unless they come into court with clean hands.'" Kauffman-Harmon, ¶ 19. Under this doctrine, we have stated that we "will not aid one who has caused title to his or her property to be transferred to another for the purpose of defrauding creditors." Kauffman-Harmon, ¶ 22.
¶ 17 In ruling on the motions to dismiss the Cowans' and Twila's complaint, Judge McLean was not bound to assume (as alleged in the complaint) that the property was held in trust for Arden's benefit. We have reviewed the sufficiency of the complaint including the attached documents. Powell, 287 Mont. at 102, 951 P.2d at 1354. We determine that the court's interpretation of the law is correct. City of Cut Bank, ¶ 6. The District Court correctly applied the applicable standard for ruling on a motion to dismiss. Powell, 287 Mont. at 102, 951 P.2d at 1354. The record supports the court's determination that Arden's interest in the property had already been adjudicated and that judgment, in turn, extinguished any derivative claim that his parents and sister may have had. The complaint and the attached documents support the court's granting of the motions to dismiss. City of Cut Bank, ¶ 20. We affirm.
*10 KARLA M. GRAY, C.J., JOHN WARNER, PATRICIA O. COTTER and JIM REGNIER, JJ., concur.
Justice JIM RICE dissenting.
¶ 18 I dissent.
¶ 19 The District Court granted Kathy's motion to dismiss on the following grounds:
[T]he deed language contains no legally enforceable ownership rights reserved by Arden's parents. Furthermore, the deed language contains no conditions or restrictions under which Arden's sister, Twila, can claim an ownership interest. Accordingly, Arden's parents and Twila have no enforceable legal ownership interests in their own right to the property. Rather the rights they seek to enforce arise solely out of Arden's equitable interest....
This is an erroneous statement of the law in several respects.
¶ 20 First, the Cowans' complaint raises a trust issue, not a property ownership issue. The absence of deed language referencing a trust is not dispositive of the issue of whether a trust was created by the parties' actions. A trust may be created by "a transfer of property by the owner during the owner's lifetime to another person as trustee," § 72-33-201(2), MCA, and may also be created by "an enforceable promise to create a trust" at a future time. Sections 72-33-201(5) and 72-33-209, MCA. Thus, the question is not whether the language within a property transfer document, here a deed, references a trust, but whether there is any evidence which "manifests an intention to create a trust," § 72-33-202, MCA, including evidence outside of the property transfer document itself. Obviously, a trust, once created, can receive various properties without the necessity of the property transfer documents reiterating the trust purpose.
¶ 21 Here, it is alleged in the Cowans' complaint that discussions between the Cowans and Kathy led to an agreement to create a trust; that, pursuant to the agreement, the Cowans created a handwritten trust document and gratuitously transferred the property to Kathy; and that Kathy, also pursuant to the agreement, executed a Will and Power of Attorney in Arden's favor. These allegations address the issue of whether a trust was properly manifested and created, and therefore, the District Court's dismissal of the action based solely upon the language of the deed was reversible error.
¶ 22 Further, the District Court erred in concluding that the Cowans' interest arose "solely out of Arden's interest." As trustors, the Cowans have a separate and independent interest in the property. Section 72-33-216, MCA, provides that where "the owner of property gratuitously transfers it ... but the trust fails, the transferee holds the trust estate as a resulting trust for the transferor...." Here, in accordance with Judge Larson's order in Arden and Kathy's dissolution proceeding, which was affirmed by this Court, the trust has failed. Consequently, the Cowans' complaint alleges that, pursuant to statute, a resulting trust has been created.
¶ 23 However, the Court essentially holds, in ¶ 14, that the dissolution decree is res judicata of Kathy's ownership of the property. However, that is error. "For res judicata to lie ... the parties or their privies must be the same" and "the issues must be the same...." Lee v. Musselshell County, 2004 MT 64, ¶ 20, 320 Mont. 294, ¶ 20, 87 P.3d 423, ¶ 20. The property ownership issues as between Kathy and Arden were resolved in the dissolution proceeding, but the trust-related issues as between Kathy and the Cowans were not determined therein, and should not be avoided by a dismissal on the pleadings.
¶ 24 I would reverse and remand for further proceedings.
Justice JAMES C. NELSON joins in the dissent of Justice RICE.
