Let $X$ be a scheme and $G$ a (commutative) constant group scheme. Consider a $G$-torsor $Y$ for $X$, by which I mean that there is a canonical isomorphism:
$$g_Y \colon Y \times_X Y \cong Y \times_X G$$
Two $G$-torsors $Y$ and $Y'$ are isomorphic to each other if and only if there is an isomorphism $Y \cong Y'$ which is compatible with $g_Y$ and $g_{Y'}$ keeping G identity.
I heard that there is a one-to-one correspondence between isomorphism classes of $G$-torsors and $\mathrm{Hom}(\pi_1(X), G)$.
I tried to see this by associating $\rho_Y \colon \pi_1(X) \to G$ to the given $G$-torsor $Y$. Assuming that $Y$ is an etale Galois covering of $X$, I suppose that I can have a correspondence
$$g_Y(y,y) = (y, \theta)$$
with $\theta \in G$. I choose an element $\sigma \in \pi_1(X)$ and let it act on $y$ getting
$$g_Y(\sigma(y), \sigma(y)) = (\sigma(y), \lambda)$$
with $\lambda \in G$ and I will define $\rho_Y \colon \pi_1(X) \to G$ by
$$\rho_Y(\sigma) \colon\!= \theta^{-1}\lambda$$
Question: With this definition of $\rho_Y$, is it easy to see that $\rho_Y(\sigma)$ is well-defined in the sense that it does $not$ depend on the chosen element $y$?
Then if so, is it easy also to see that $\rho_Y$ is a group homomorphism?