You are doing well: first find a basis $(e_1,\ldots,e_r)$ for $W$.
Then, remember that every linearly independent subset of $V$ can be extended to a basis. Since $(e_1,\ldots,e_r)$ is linearly independent, we can extend it to a basis: $(e_1,\ldots,e_r,f_1,\ldots,f_{n-r})$, where $n=\dim(V)$, $r=\dim(W)$, $r\leq n$.
Then remember that a linear transformation may be specified by saying what it does to a basis: proceeding as you did before, send each and every one of $e_1,\ldots,e_r$ to $0$.
How do we ensure nothing else is mapped to $0$? How about mapping each $f_i$ to itself?
Suppose $a_1e_1+\cdots+a_re_r + b_1f_1+\cdots+b_{n-r}f_{n-r}$ is mapped to $0$. That means that $\begin{align*} 0 &= T(a_1e_1+\cdots+a_re_r+b_1f_1+\cdots+b_{n-r}f_{n-r})\\ &= a_1T(e_1)+\cdots+a_rT(e_r) + b_1T(f_1) + \cdots + b_{n-r}T(f_{n-r})\\ &= a_10 + \cdots +a_r0 + b_1f_1 + \cdots + b_{n-r}f_{n-r}\\ &= b_1f_1+\cdots+b_{n-r}f_{n-r}. \end{align*}$ What can we conclude about $b_1,\ldots,b_{n-r}$?
Now, it is easy to find the matrix of $T$ with respect to the basis $(e_1,\ldots,e_r,f_{1},\ldots,f_{n-r})$. What is it? Express the image of each basis vector in terms of the basis vectors, and those are the columns of the matrix of $T$.