Group question: only one element $x$ with order $n>1$, then $x\in Z(G)$

I just tried to solve this question on a exam:

Let $G$ be a group with only one element $x$ of order $n$, $n$ natural. Show that $x\in Z(G)$. (I’m using multiplicative notation)

$Z(G)$ is the subset of G such that every element of $Z(G)$ commutes with every element of G (called the Center of G).

I tried to do it like this: Suppose that x does not commute with at least one $g\in G$. Then $xg\neq gx\rightarrow x\neq gxg^{-1}$. Then,

$x^n\neq (g x g^{-1})^n=g x g^{-1}g x g^{-1}…g x g^{-1}=xx…x=gx^ng^{-1}=1$

Notice that $g x g^{-1}$ cannot have an order $n < m$ because its order depends exclusively of the order of $x$, which is $n$.

That means that there are two distinct elements in $G$ with order $n$, which is a contradiction.

Can someone tell me if it was done correctly?

Solutions Collecting From Web of "Group question: only one element $x$ with order $n>1$, then $x\in Z(G)$"

you should know that for any $g\in G$ the order of $g^{-1}xg$ equal with order of x so for any $g\in G$ $g^{-1}xg=x$ then we have $x\in Z(G)$