Show that $Z_{red}=(Z,\mathcal{O}_{Z_{red}})$ is a scheme and it satisfies the universal property

I am trying to show that, given a scheme $(X,\mathcal{O}_X)$ and a closed subset $Z\subset X$, with the subsheaf $$\mathcal{I}^Z_X(U)=\{f\in\mathcal{O}_X\mid f(z)=0 \forall z\in Z\}.$$ Then define a sheaf on $Z$ by $$\mathcal{O}_{Z_{red}}=i^{-1}\left(\mathcal{O}_X/\mathcal{I}^Z_X\right)$$ $Z_{red}=(Z,\mathcal{O}_{Z_{red}})$ is a scheme and it satisfies the universal property $$\operatorname{Hom}_{\operatorname{Sch}}(Y,{O}_{Z_{red}}) =\{f:Y\to X\mid f(Y)\subset Z\}$$ for all reduced schemes $Y$.

Assuming $Z_{red}$ is a scheme this is what I think I have to do for the Hom part For a map $f:Y\to X$ construct the morphism from $Y$ to $Z_{red}$ as follows : $f$ is already the set map $Y$ to $Z_{red}$, now if map of sheaves $\mathcal{O}_{Z_{red}}$ to $f_*\mathcal{O}_{Y}$ is given then the map from $\mathcal{O}_X/\mathcal{I}^Z_X$ to $f_{\mathcal{O}_Y}$ is also given , that is we have to show that the map from $\mathcal{O}_X$ to $f_*\mathcal{O}_Y$ is taking $\mathcal{I}^Z_X$ to $0$. Now, we have to check it for local affine that is take a affine $U$ in $X$. Then take a section of $\mathcal{I}^Z_X$ on $U$ and show that section is $0$ on $f_*\mathcal{O}_Y$. That is we have to show that the pullback of that section on $f^{-1}U$ is $0$. Then I guess It is sufficient to show that for any affine in $f^{-1}U$. But I am not able to show this.

If somebody could help me with these two proofs (both the part namely, Hom and $Z_{red}$ is a scheme) I would really appreciate it.

P.S. Please elaborate your statements.


For the second part: let $s \in \mathcal{I}_X^Z(U)$, we want to show that $t=f^{\sharp}s \in \mathcal{O}_Y(f^{-1}(U))$. Now, for all $y \in f^{-1}(U)$, $s$ is in the maximal ideal of $\mathcal{O}_{X,f(y)}$, so by definition $t_y$ is in the maximal ideal of $\mathcal{O}_{Y,y}$. In other words, $t$ vanishes at every point where it is defined. It follows from commutative algebra that the restriction of $t$ to any affine open subset is nilpotent. As $Y$ is reduced, $t$ restricts to the zero section of any affine subset, so is zero, as was required.

(Then you showed that the natural map $\mathrm{Hom}_{\mathrm{Sch}}(Y,Z_{red}) \rightarrow \{f:Y \rightarrow X,\, f(Y) \subset Z\}$ was surjective. It's easy to see that it's injective.)

To check that $Z_{red}$ is a scheme (as a topological space, it is a closed subspace of $X$), it's enough to see that for every affine open subset $U \subset X$, $Z_{red} \cap U$ is a scheme. In other words, given the construction, we can assume that $X$ is the spectrum of a ring $A$, and $Z=V(I)$ for an ideal $I \subset A$ and $\sqrt{I}=I$.

We want to show that $Z_{red}$ is $\mathrm{Spec}\,A/I$, ie we want to show that the structure sheaf of $A/I$ is $i^{-1}\mathcal{O}_X/\mathcal{I}_X^Z$. But it's easy to see that $\mathcal{I}^Z_X(D(f)) = I_f$ and thus $\mathcal{O}_X/\mathcal{I}_X^Z$ is $D(f) \longmapsto A_f/I_f \cong (A/I)_f$. But it's easy to see that $(A/I)_f$ depends only on $D(f+I)=D(f) \cap Z$, and it follows formally that $i^{-1}(\mathcal{O}_X/\mathcal{I}_X^Z)(D(f) \cap Z) = (A/I)_f$, QED.