When are the sections of the structure sheaf just morphisms to affine space? Let $X$ be a scheme over a field $K$ and $f\in\mathscr O_X(U)$ for some (say, affine) open $U\subseteq X$. For a $K$-rational point $P$, I can denote by $f(P)$ the image of $f$ under the map
$$\mathscr O_X(U) \to \mathscr O_{X,P} \twoheadrightarrow \mathscr O_{X,P}/\mathfrak m_P = K.$$
This yields a map $f:U(K)\to K$. Giving $U$ the induced subscheme structure, when does this uniquely define a morphism $f:U\to\mathbb A_K^1$ of schemes? It certainly works when $X$ is a variety (and $K$ algebraically closed), so there should be some "minimal" set of conditions for this interpretation to make sense. Thanks a lot in advance!

As $U$ is also a $K$-scheme, we can forget about $X$ and think only about $U = \mathrm{Spec} A$. $U$ being a $K$-scheme means that there's a structure morphism $U \to \mathrm{Spec} K$, which gives us a structure map of rings $K \to A$. 
Now, every $K$-scheme morphism $U = \mathrm{Spec} A \to \mathrm{Spec} K[x] = \mathbb{A}_K^1$ is determined by a ring homomorphism $\phi: K[x] \to A$, such that $\phi|_K : K \to A$ is a structure morphism of a $K$-scheme $U$. Universal property of polynomial rings says that giving such homomorphism is equivalent to picking any element in $A$ and mapping $x$ to it. So, for any $f \in \mathcal{O}_U(U) = A$, we have a scheme morphism $U \to \mathbb{A}_K^1$, and all such morphisms arise in this way.
Note that you don't even need to assume that $U$ is affine: we use only the fact that scheme morphisms $U \to \mathrm{Spec} K[x]$ are determined by ring homomorphisms $K[x] \to \mathcal{O}_U(U)$.
Could you elaborate more on what is $U(K)$, and how does your composition define a morphism $U(K) \to K$?
