Help with an algebraic geometry result I am studying this part of algebraic geometry and I have come to this proposition. I understand the basic idea well but there are two details that escape me.

Proposition: Let $G$ be a finite group acting linearly over $X$,
affine closed. Then, exsist an affine closed $Y$ and a surjective
morphism $\psi:X \rightarrow Y$ such that $K[Y]=K[X]^G$ and $\psi^*$
is the inclusion map $K[X]^G \subset K[X]$.  Furthermore, for all
$p,q$ in $X$ $$\psi(q)=\psi(p) \iff \exists g \in G :\;\;\;q=gp$$


Proof of the second part (within my notes)
$\Leftarrow$  Let $p,q$ points in $\mathbb{A}^n$ such that $\;\exists g \in G :\;q=gp. \;\;$ For all $f \in K[X]^G$ we have $f(q)=f(gp)=f^g(p)=f(p)$, so
$$f(\psi(q))=\psi^*(f(q))=f(q)=f(p)=\psi^*(f(p))=f(\psi(p))$$ Then
$\psi(p)=\psi(q)$.
$\Rightarrow$ Let $p,q$ points in $\mathbb{A}^n$ such that
$\psi(p)=\psi(q)$. Supposte that $\not\exists g \in G: \;\; q=gp$.
Choice $f \in I_X(p)$  [i.e.$f\in K[X], f(p)=0$]   but $f(gq)\neq0
> \;\; \forall g \in G$
So $h=\prod_{g\in G} f^g$ is such that $h \in K[X]^G$, $h(p)=0$
because $f$ is a factor, $h(q)=\prod_{g\in G}    f^g(q)=\prod_{g\in G}
> f(gq) \neq 0$
This implies $h(\psi(q))=\psi^*(h(q))=(h(q))\neq
> h(p)=\psi^*(h(p))=h(\psi(p))$. Absurd because $\psi(p)=\psi(q)$.


I didn't understand these two steps:

*

*Why $f(\psi(p))=f(\psi(q))$ implies $\psi(p)=\psi(q)$?
I don't understand how this works, since f is non-injective

*What guarantees me that such a function exists?
I tried to prove this with a proof by contradiction but I couldn't.


For 2.  had thought of proceeding like this:
Being $O(p)$ and $O(q)$, i.e. orbits of $p$ and $q$, G-invariant and disjoint closed of X, their respective ideals are G-invariants:
$$f(p)=0 \Rightarrow f \in I(O(p))\Rightarrow Z(f) \subset Z(I(O(p)))=O(p)$$
$$f(gq)=f^g(q)=0 \Rightarrow f^g \in I(O(q))\Rightarrow f \in I(O(q)) \Rightarrow q \in Z(f) \subset O(p)$$
absurd since $q \in O(q)$ and $O(q)\cap O(p)=\emptyset$
All this only works if and oly if $O(p)$ and $O(q)$ are closed
BUT CAN I SAY THAT $O(p)$ AND $O(q)$ ARE CLOSED?
 A: I'm guessing that this is about varieties over an algebraically closed field. If I'm right, then the answers are:

*

*This proves that for every $f\in K[X]^G$, $f(\psi(p))=f(\psi(q))$. One of these functions is not necessarily injective, but the first part of the proposition says that $K[X]^G$ is an affine closed variety, i.e. a closed subset in some affine space. Therefore, there are functions $f_1,\ldots ,f_N$ such that $(f_1,\ldots ,f_N):Y\to \mathbb A^N$ is a closed embedding (in particular injective), and since $(f_1,\ldots ,f_N)(\psi(p)) = (f_1,\ldots ,f_N)(\psi(q))$, this means that $\psi(p)=\psi(q)$.


*We are proving the contrapositive. If $p\neq gq$ for all $q$, then $\psi(p)\neq \psi(q)$. The first claim we want to prove is that if $p$ is not in the finite set $G\cdot q = \{gq\colon g\in G\}$, then there is a function $f$ that vanishes at $p$ but nowhere in $G\cdot q$. In fact, we can take a linear function: say we have coordinates of $\mathbb A^n$, $(x_1,\ldots ,x_n)$, such that $p$ is the origin. Then we are looking for a function of the form $f = \sum a_ix_i$. The condition that $f(gq)=0$ is a nonzero linear equation in the $a_i$'s. If we say that $\overline{a} = (a_1,\ldots ,a_n)\in \mathbb A^n$, to $gq$ corresponds a hyperplane $H_g$ in $\mathbb A^n$, and $f(gq)\neq 0\Leftrightarrow \overline a\notin H_g$. So, there exists $\overline{a}$ such that $f(gq)\neq 0$ for all $g$ if and only if $\mathbb A^n\setminus (\bigcup_{g\in G} H_g)$ is not empty. But affine space is not a finite union of hyperplanes*, so we are done.
*(It's crucial that $K$ is algebraically closed, and therefore infinite: if $K$ is finite, then affine space is a finite union of hyperplanes)

Why affine space is not a finite union of hyperplanes: We prove this for $\mathbb A^n$ by induction on $n$. For $n=1$, hyperplanes are points and if $K$ is infinite, then we are done. Now, for general $n$, say our hyperplanes are $H_1,\ldots , H_m$. There are infinitely many planes parallel to $H_1$ (because the field is infinite), so one of them, say $H'$, must be different from all of $H_1,\ldots ,H_m$. This means that $H'\cap H_j\subsetneq H'$ for all $j$. $H'$ is an affine space of dimension $n-1$, and each $H'\cap H_j$ is either a hyperplane in $H_j$ or it is empty (as it can't equal $H'$). By induction, there is a point $p\in H'$ not contained in any of the hyperplanes.
