Why the surjective map $\pi: X \rightarrow X/G$ verifies the universality property? I am working about that the quotient of an affine set by a finite group has also a structure of an affine set.
In Algebraic Geometry by J.Harris (pgs 124-125) there is a construction of $Y = X/G$ given $X$ an affine set and $G$ a finite group.
He defines $A(Y)$ as $A(X)^G$ and proves that $Y$ has an affine set structure and that its points correspond to the orbits of $X$ by the action of $G$.
He also proves that the projection $\pi: X \rightarrow Y$ is surjective.
(The way he do this is natural. Every time he uses the definition of $A(Y)$ and its properties.)
Until here, everything is clear and the only thing we must do is to prove that the map $\pi$ satisfies the universality property, i.e.,
every morfism $\rho:  X\longrightarrow Z$ factors through $\pi$ if and only if 
$\rho(p) = \rho(gp)$ for every $x \in X$ y $g \in G$.
\begin{equation*}
\begin{gathered}
X\\
^\rho\swarrow \: _\varphi \: \searrow ^\pi\\
Z \enspace \longleftarrow \enspace Y
\end{gathered}
\end{equation*}
Unfortunately I don't know how to do this. If someone can help me it would be great.
By the way, I know that this result also is true in the category of affine schemes, but I don't have the knowledge to understand that proof. I am only interested in the case of affine sets of the affine space $\mathbb{A}_k^n$.
Thank you in advance!
 A: It all goes back to set theory. 
In fact let $A$ be a set and consider equivalence relation $\sim$ on $A.$ Then we have quotient $A/\sim$ and natural projection $\pi:A\to A/\sim.$

Thm. For any set $B$ and any function $f:A\to B$ we have that
$f$ factors through $\pi$ (i.e. $f=g\pi$ for some $g:A/\sim \to B$)
  if and only if for every $x,y\in A$ condition $x\sim y$ implies
  $f(x)=f(y).$ 
In addition this factorization is unique.

Proof. $\rightarrow$ implication is obvious. 
$\leftarrow$ implication: Condition 
$$\forall(x,y\in A)(x\sim y\implies f(x)=f(y))$$ 
means precisely that function $g:A/\sim \to B$ defined by formula $g([x])=f(x)$ is well defined.
Uniqueness is obvious, because functions $g_1,g_2$ have to satisfy $g_1([x])=f(x)=g_2([x])$ for all $x.$
Now you just put for set $A$ your affine set and for $\sim$ relation which glues together elements from the same orbit.
I purposely made proof in such generality, to show that sometimes it is easier to look from broader perspective.
I hope now you will be able to do rigous proof of your case.
