Show that points on a smooth manifold can be separated by smooth function

I need to show that given $$x,y\in M, x\neq y$$ where $$M$$ is a smooth manifold, $$\exists$$ a smooth function $$f:M\longrightarrow \mathbb{R}$$ such that $$f(x)=0, f(y)=1.$$

Attempt of the proof: Since $$M$$ is a smooth manifold, there exists an atlas $$\{(U_\alpha,\phi_ \alpha)\}_{\alpha\in\mathbb{N}}$$ such that all transition maps are smooth. Take two charts $$(U_1,\phi_1),(U_2,\phi_2)$$ such that $$x\in U_1,y\in U_2$$ and $$U_1\cap U_2\neq \emptyset$$, where $$\phi_1:U_1\longrightarrow V_1,\phi_2:U_2\longrightarrow V_2$$ are homeomorphisms, and $$V_1,V_2\subset \mathbb{R^n}$$ are open. By the definition of smooth manifold, I know that the transition map $$\phi_2 \phi_1^{-1}:\phi_1(U_1\cap U_2)\subset \mathbb{R^n}\longrightarrow \phi_2(U_1\cap U_2)\subset \mathbb{R^n}$$ is smooth. I now need to create a smooth map $$f:M\longrightarrow \mathbb{R}$$ that satisfies the required property.

In my definition $$f:M\longrightarrow \mathbb{R}$$ is smooth if for any coordinate chart $$(U,\phi)$$, $$f\phi^{-1}:\phi(U)\subset \mathbb{R^n}\longrightarrow\mathbb{R}$$ is smooth.

EDIT: One natural thing that I could do in this case is to send $$U_2$$ to $$V\subset\mathbb{R}$$ by a homeomorphism. I think that is not possible, especially if the dimension of the maniold is $$> 1$$. If that was the case, the transition map is smooth, but still would not fulfill the requirement of my smooth function $$f.$$
Let $(U,\phi)$ be a chart around $y\in U$ such that $x\not\in U$ and let $V=\phi(U)\subset \mathbb{R}^n$. Now choose a smooth and compactly supported function $g\in C_c^\infty(V)$ such that $g(\phi(y))=1$. This is possible, just take a variant of a standard mollifier. This gives you a smooth, compactly supported function (smooth as composition of smooth maps)
$$f=g\circ\phi:U\rightarrow \mathbb{R}$$
Because the function has compact support, you can just extend it by $0$ to all of $M$ and it will still be smooth. This gives you a smooth function $f:M\rightarrow\mathbb{R}$ such that $f(x)=0$ and $f(y)=1$.