kindly tell me if I am correct or not.
Let $G_1$ and $G_2$ be two groups such that $|G_2|=p$ (a prime). Let $\varphi:G_2 \rightarrow Aut(G_1)$ be a group homomorphism defining the semidirect product $G=G_2 \ltimes_{\varphi} G_1$. Note that the center $Z(G_2 \ltimes_{\varphi} G_1)=(Z(G_1) \cap Fix(\varphi)) \times (Z(G_2) \cap Ker (\varphi))$. If $\varphi$ is not trivial (that is the semidirect product is not a direct product), then $Ker(\varphi)$ is trivial. This implies that $Z(G) \subseteq G_1$.