In Hartshorne we have Exercise II.5.3:
$\newcommand\spec{\mathrm{Spec}}\newcommand\hom{\mathrm{Hom}}$ Given an affine scheme $X=\spec A$, an $A$-module $M$ and a sheaf of $\mathcal O$-module $\mathcal F$ (where $\mathcal O$ is just the natural sheaf structure of $A$), there is a natural bijection
$$\hom_A(M,\mathcal F(X)) \longleftrightarrow \hom_{\mathcal O}(\widetilde M, \mathcal F)$$
where $\widetilde M$ is the sheaf of $\mathcal O$-module induced by $M$.
I was wondering how general this can be. I think we need not necessarily assume $X$ is affine, do we? For instance, wouldn't an arbitrary scheme $X$ (with structure sheaf $\mathcal O$) and an $A:=\mathcal O(X)$ module $M$ give us such a bijection (proof in a similar fashion as affine $X$ with some gluing)? I think this shouldn't be true because the global section of the sheaf $\mathcal O$ does not completely determine the sheaf for a non-affine scheme $X$. If this is not true, then for which schemes $X$ is this true?
See lemma 17.10.5 and 26.7.1 of the stacks project. There is a generalization that holds for all ringed spaces.
For any morphism $f : X \rightarrow Y$ of ringed spaces, the functors $(f^*, f_*)$ are adjoint. In particular, if $Y$ is a one-point space with $O_Y(Y) = R$, then a morphism $f : X \rightarrow Y$ corresponds to a ring homomorphism $R \rightarrow O_X(X)$, and $f_*$ corresponds to global sections.
Let $X = \operatorname{Spec}(A)$, then, $\widetilde{M}$ is $f^* M$ , where $f^*$ is the morphism $X \rightarrow $ (the one point space with structure sheaf $A$). In this way, the $\widetilde{-}$ and global sections adjunction is a special case of the $(f^*, f_*)$ adjunction, which holds for all ringed spaces.