[proofplan]
We use the lower central series of $\mathfrak g$. Nilpotence means that this series eventually becomes zero. Taking the last non-zero term before it vanishes gives a non-zero subspace whose bracket with all of $\mathfrak g$ is zero, and hence this subspace lies inside the centre.
[/proofplan]
[step:Choose the last non-zero term of the lower central series]
Define the lower central series $(\mathfrak g_r)_{r \in \mathbb N}$ of $\mathfrak g$ by
\begin{align*}
\mathfrak g_1 &:= \mathfrak g, \\
\mathfrak g_{r+1} &:= [\mathfrak g,\mathfrak g_r]
:= \operatorname{span}_k\{[x,y] : x \in \mathfrak g,\ y \in \mathfrak g_r\}
\quad \text{for } r \in \mathbb N.
\end{align*}
Since $\mathfrak g$ is nilpotent, there exists $m \in \mathbb N$ such that $\mathfrak g_m = 0$. Since $\mathfrak g_1 = \mathfrak g \ne 0$, the set
\begin{align*}
A := \{r \in \mathbb N : \mathfrak g_r = 0\}
\end{align*}
is non-empty and does not contain $1$. Let $m := \min A$. Then $m \ge 2$, $\mathfrak g_m = 0$, and $\mathfrak g_{m-1} \ne 0$.
[/step]
[step:Show the last non-zero term is central]
We prove that $\mathfrak g_{m-1} \subset Z(\mathfrak g)$. Let $z \in \mathfrak g_{m-1}$ and let $x \in \mathfrak g$. By the definition of the lower central series,
\begin{align*}
[x,z] \in [\mathfrak g,\mathfrak g_{m-1}] = \mathfrak g_m.
\end{align*}
Since $\mathfrak g_m = 0$, it follows that $[x,z] = 0$. Because $x \in \mathfrak g$ was arbitrary, $z \in Z(\mathfrak g)$.
[guided]
The goal is to prove that every element of $\mathfrak g_{m-1}$ commutes with every element of $\mathfrak g$. Take an arbitrary element $z \in \mathfrak g_{m-1}$ and an arbitrary element $x \in \mathfrak g$. The bracket $[x,z]$ belongs to the subspace generated by all brackets between elements of $\mathfrak g$ and elements of $\mathfrak g_{m-1}$, namely
\begin{align*}
[x,z] \in [\mathfrak g,\mathfrak g_{m-1}].
\end{align*}
By the recursive definition of the lower central series, this subspace is exactly $\mathfrak g_m$. But $m$ was chosen so that $\mathfrak g_m = 0$, hence
\begin{align*}
[x,z] = 0.
\end{align*}
Since this holds for every $x \in \mathfrak g$, the defining condition for membership in $Z(\mathfrak g)$ is satisfied. Therefore $z \in Z(\mathfrak g)$, and so $\mathfrak g_{m-1} \subset Z(\mathfrak g)$.
[/guided]
[/step]
[step:Conclude that the centre is non-zero]
From the choice of $m$, the subspace $\mathfrak g_{m-1}$ is non-zero. From the previous step, $\mathfrak g_{m-1} \subset Z(\mathfrak g)$. Therefore $Z(\mathfrak g)$ contains a non-zero element, and hence
\begin{align*}
Z(\mathfrak g) \ne 0.
\end{align*}
This proves the theorem.
[/step]