I wish to prove the following: For every scheme $X$ there exists a unique morphism of schemes $X\rightarrow Spec(\mathbb{Z})$.
Here is what I have so far: if $X$ is affine, say $X\simeq Spec(A)$ for a ring $A$, I know that morphisms of schemes $Spec(A)\rightarrow Spec(B)$ are in one to one correspondence with ring homomorphisms $B\rightarrow A$. Any homomorphism $\phi:\mathbb{Z}\rightarrow A$ must satisfy $\phi(1) = 1$ and is thus unique.
If $X$ is a scheme, we have an open cover $(X_i)_{i\in I}$ such that $(X_i,\mathcal{O}_{X}\mid X_i ) \simeq (Spec(A_i),\mathcal{O}_{Spec(A_i)})$ and hence, there are unique morphisms $f_i:(X_i,\mathcal{O}_{X}\mid X_i )\rightarrow (Spec(\mathbb{Z}),\mathcal{O}_{Spec(\mathbb{Z})})$.
Now I would like to construct a global morphism $f$ by glueing together the local parts $f_i$ but I am not sure how (or even if) this works.