Flatness, Hilbert polynomial and reduced schemes. Let $f:X \to S$ be a projective morphism of schemes and $F$ a coherent $O_X$-module. We have that if $F$ is $S$-flat then the Hilbert polynomial $P(F_s)$ is locally costant as a function of $s \in S$. (for reference http://carlossicoli.free.fr/H/Huybrechts_D.,_Lehn_M.-The_Geometry_of_Moduli_Spaces_of_Sheaves,_Second_Edition_(Cambridge_Mathematical_Library)(2010).pdf, proposition 2.1.2). The converse is true if $S$ is reduced. Can you give me an example with $S$ not reduced, $P(F_s)$ locally costant but $F$ not $S$-flat?
 A: Let $X=S=\textrm{Spec }D$, where $D=\mathbb C[t]/t^2$, and let $f$ be the identity on $S$.
Let $F$ be the $\mathcal O_X$-module $\tilde M$, where $M=D/tD\cong \mathbb C$. 
Aside. There is a criterion, which I learnt on Hartshorne's notes/book on Deformation Theory, saying that a $D$-module $M$ is flat (over $D$) if and only if the natural map ("multiplication by $t$") $M/tM\to M$ is injective. In other words, it is enough to check that the sequence $$0\to tD\to D\to \mathbb C\to 0$$ stays exact after taking $M\otimes_D-$.
Back to our $F$: it is not flat over $S$. Or, $M$ is not flat over $D$. Indeed, tensoring the inclusion $tD\to D$ with $M$ we get $M\otimes_DtD\to M\otimes_DD$, which is the zero homomorphism $\mathbb C\to\mathbb C$.
Added. (Example of a nonflat family).
Let $S=\mathbb A^1$, and $X\subset\mathbb A^1\times \mathbb P^3$ the family given by $$X_s=\{x_2=x_3=0\}\cup\{x_1=x_3-sx_0=0\}\subset \mathbb P^3.$$ The first component is always a line. If $s\neq 0$, the second component is another line, disjoint from the first. Hence $HP_{X_s}=2T+2$ in this case. But $X_0=\{x_1x_2=x_3=0\}$ is a reducible plane conic. Hence $HP_{X_0}=2T+1$. Conclusion: $F=\mathcal O_X$ is not $S$-flat, i.e. $X\to S$ is not flat.
