Open Set is $G_{\delta}$ set In any metric space prove that every open set is $G_{\delta}$ set and every closed set is $F_{\sigma}$ set.(Hint: use the continuity of $x\longmapsto d(x,A)$.)
I tried to prove this by saying: If $U$ is a open set, consider $\bigcup_{i=0}^{\infty} A_{n}$, where $A_{n}=\bigcup_{x\in U} B(x,1+1/n)$ and $A_{0}=U$.
Hence every Open set is $G_{\delta}$ set.
Also I didn't get how to use the hint to solve the problem. 
Thanks in advance.
 A: The hint suggests to do this:
Let $A$ be a closed set and $f \colon x\mapsto d(x,A)$.
If you can show that $f$ is continuous (can you?), then you get that every $A_n=f^{-1}(-\infty,\frac1n)=\{x\in X; d(x,A)<\frac1m\}$ is open. (One of equivalent conditions to continuity is that preimage of any open set is open.)
Now you should show that $A=\bigcap\limits_{n=1}^\infty A_n$. (In the proof, the closedness of $A$ should be used. Do you know how to show this?)
This shows that every closed set is an intersection of countably many open sets, so it is a $G_\delta$-set.
See also this closely related question: Are all compact sets in $ \Bbb R^n$, $G_\delta$ sets?

If you copied the assignment correctly, it is in fact much easier.
If $A$ is closed set that $A$ is union of a system containing a single closed set - namely the set $A$. So it is $F_\sigma$. 

I only mentioned closed sets. Analogous facts for open sets can be shown by taking complements.
A comment on what you suggested in you post as a solution. 
If you define $A_n=\bigcup_{x\in U} B(x,1+1/n)$ then already $A_1$ is a proper superset of $U$ if, for example, $U=(0,1)$ in $\mathbb R$. 
So, in this example, you have $\bigcup_n A_n \supseteq A_1 \supsetneqq U$ and you definitely can't prove $U=\bigcup_n A_n$.
A: You must have switched things. There is no need for metrizability to prove that open sets are $G_\delta$, nor that closed sets are $F_\sigma$--both of these follow immediately from the definitions of $G_\delta$ and $F_\sigma$.
Now, since a set is $G_\delta$ if and only if its complement is $F_\sigma$, and closed if and only if its complement is open, then we need only prove that every closed set in a metric space is $G_\delta$.
Take any closed set $A$ in a metric space $X$. Let $f(x)=d(x,A)$, so continuity of $f$ means that preimages of open sets are open. In particular, for each integer $n\geq 1$, let $A_n$ be the preimage of $(-1/n,1/n)$. The intersection of all the $A_n$ is then precisely the set of all $x\in X$ such that $f(x)=d(x,A)=0$. Since $A$ is closed, then $d(x,A)=0$ if and only if $x\in A$. Thus, $A=\bigcap_{n=1}^\infty A_n$, so $A$ is $G_\delta$.
