No change.
Let $\mathcal{X}$ denote the relative scheme $X \xrightarrow{\pi} S$. I use a different letter so that we can distinguish between "schemes" and "schemes over $S$".
Let $\mathbb{A}^1 = \mathrm{Spec}(\mathbb{Z}[x])$ denote the "affine line". For a scheme $S$, let $\mathbb{A}^1_S = \mathbb{A}^1 \times S$ denote the "affine line over $S$".
Recall that the structure sheaf is conceived of as the collection of algebraic functions. In fact, we can make this rather literal: the structure sheaf is a representable presheaf! There is a natural (in $U$) isomorphism $\mathcal{O}_X(U) \cong \hom_{\mathbf{Sch}}(U, \mathbb{A}^1)$.
Given a scheme $\mathcal{X}$ over $S$ viewed as an $S$-indexed family of schemes, we can think of there being functions on $\mathcal{X}_s$. There are a few ways how we might aggregate these together; the one we want is:
- A function on $\mathcal{X}$ is an $S$-indexed family of functions
This boils down to the same thing as "a function on $X$". If this isn't clear, compare with the case of sets: given a family $f_s$ of functions, we can construct a new function $g$ by $g(s,x) = f_s(x)$. Conversely, given $g$, we can reconstruct the family $f_s$.
An alternative is that we might ask for an $S$-indexed family of function spaces. I don't know if this higher-order notion has any reasonable incarnation in algebraic geometry.
Another reason why this is the right thing is that we want algebraic geometry over $S$ to mimic algebraic geometry over $\mathbb{Z}$. Central to this is the role of the affine line; we would like functions on $\mathcal{X}$ to be maps to the affine line over $S$! That is,
$${\mathcal{O}}_{\mathcal{X}} \cong \hom_{\mathbf{Sch}/S}(-, \mathbb{A}^1_S) $$
However, we have a general identity for any relative scheme $\mathcal{X}$ and ordinary scheme $Y$:
$$ \hom_{\mathbf{Sch}/S}(\mathcal{X}, Y \times S \to S) \cong \hom_{\mathbf{Sch}}(X, Y) $$
So, $\mathcal{O}_{\mathcal{X}}$ and $\mathcal{O}_X$ should be basically the same thing.