Let $X$ be a nonempty, connected, proper scheme over a field $k$, and $f \in \mathcal{O}_X(X)$ (the global sections of $X$). Let $\varphi : X \to \mathbb{A}^1_k$ be the morphism induced by: $$\begin{align*} k[T] & \to \mathcal{O}_X(X) \\ T & \mapsto f \end{align*}$$
ie. $\varphi$ comes from the isomorphism $\mathrm{Hom}(X, \mathbb{A}^1_k) \simeq \mathrm{Hom}(k[T], \mathcal{O}_X(X))$. I would like to prove:
$\varphi(X)$ is a closed point of $\mathbb{A}^1_k$
Now, thanks to a previous question that I asked, I know that $\varphi(X)$ is a closed subset of $\mathbb{A}^1_k$. It is also connected, as $X$ is connected. Now, the only subsets of $\mathbb{A}^1_k$ matching these requirements are closed singletons and the whole set. So now I'm reduced to showing that there's no surjective morphism $X \to \mathbb{A}^1_k$... And this is where I'm stuck.
Intuitively the problem would come from the fact that $\eta$, the generic point of $\mathbb{A}^1_k$, can't lie in the image of $\varphi$. Let's assume it does, $\varphi(x) = \eta$. This gives rise to an extension $k(T) \hookrightarrow \kappa(x)$, which, given the description of $\varphi$, is $T \mapsto f(x) \in \kappa(x)$, and therefore $f(x)$ is transcendental in $\kappa(x)$. I think I'm not too far from the answer, but I'm stuck.