If $(Y,\mathcal{O}_Y)$ is an affine variety, show that $\operatorname{Hom}_\text{prevar}(-,Y)$ is a sheaf of sets. If $(Y,\mathcal{O}_Y)$ is an affine variety, show that $\operatorname{Hom}_\text{prevar}(-,Y)$ is a sheaf of sets.
The definitions that I am using are:


*

*An affine variety $(Y,\mathcal{O}_Y)$ is an irreducible ringed space that is isomorphic to an affine algebraic set.

*A prevariety $(X,\mathcal{O}_X)$ is an irreducible ringed space covered by open affine varieties $\{U_i\}$.

*A morphism of prevarieties is a continuous map $f:X\to Y$ such that for all open subsets $W\subseteq Y$ we have $f^{\ast}\mathcal{O}_Y(W)\subseteq \mathcal{O}_X(f^{-1}(W))$, where $f^{\ast}(g)=g(f)$.


It is clear that $\operatorname{Hom}_\text{prevar}(-,Y)$ satisfies the sheaf axioms except the gluing property. Assume that $X$ is a prevariety and $U\subseteq X$ is an open subset with $U=\cup V_i$, where the $V_i$'s are open in $U$. If $f_i\in \operatorname{Hom}_\text{prevar}(V_i,Y)$ and $f_i|_{V_i\cap V_j}=f_j|_{V_i\cap V_j}$ for all $i,j$, we need to show that there exists a unique $f\in\operatorname{Hom}_\text{prevar}(U,Y)$ with $f|_{V_i}=f_i$ for all $i$.
I tried using that $\operatorname{Hom}_\text{prevar}(V_i,Y)=\operatorname{Hom}_{k\text{-alg}}(\mathcal{O}_Y(Y),\mathcal{O}_U(V_i))$, but I cannot get any further. This is not a homework problem.
 A: What is your definition of morphism of prevarieties? 
If it involves a continuous map plus a map of sheaves between the structure sheaf on the target space and the direct image of the structure sheaf of the source (that induces morphisms of local rings on the stalks), then you may want to prove in general:


*

*If two sheafs $F$ and $G$ are given over a topological space $X$, then the presheaf of sheaf morphisms is actually a sheaf. (For this you have to use that $F$ and $G$ are both sheaves to define were a section should go.)

*If two sheaves of rings are given over a space $X$, then the presheaf of sheaf morphisms that induce local ring homomorphisms on on stalks is actually a sheaf. (This follows from 1 quickly.)


(A morphism of local rings $(A,M)$ to $(B,N)$ is one that sends the maximal ideal $M$ into the maximal ideal $N$. It is helpful to this of this as something that sends a function vanishing at $m$ to one vanishing at $n$, and one not vanishing at $m$ to one not vanishing at $n$.)
Let me know if you want more detail.
Edit:
@John In the update to your answer, what exactly do you mean by "pulls-back" and $k$-valued functions? 
There is something missing from this description, which is that you should require something like that restricting followed by pulling back is the same as pulling back followed by restricting. If your definitions are "correct", I think you will find that it means exactly the same thing as what I suggested. The details of this stuff can be very confusing - I highly recommend reading Ravi Vakil's notes if you want to learn more algebraic geometry. 
Anyway, try the following: You want to define $f \in Hom(U,Y)$. Since continuous maps glue (they glue as maps of sets, then you can check that continuity can be checked locally), you can define this on the level of sets by gluing the $f_i$, and you just need to define how $f$ pulls back sections over opens $Y$. What you can do is pull back these sections using the $f_i$ to sections over $V_i$ and then show that these new sections agree on the overlaps (this is where you use that the functions $f_i$ agree on the overlaps), and glue their images together to define $f^*(s)$ as a section on $U$. Y
