Find idempotent elements of $S$ the set of maps $f:X \rightarrow R$ where $X$ is a given set and $R$ is a given ring with the operations defined by $(f+g)(r)=f(r)+g(r)$ and $(fg)(r)=f(r)g(r)$ where the sum and the product in these expressions are taken in $R$.
$f\in S$ is idempotent if $f^2=f$. Then for any element $x\in X$, we have that $f^2(x)=(f\cdot f)(x)=f(x)f(x)=[f(x)]^2$.
Hence the problem is when the equality $[f(x)]^2=f(x)$ holds. Since $R$ is a ring, we can add the opposite in both sides and we have that $[f(x)]^2-f(x)=0$ where $0$ is the neutral element in $R$.
But, the only nilpotent elements are $0$ and $1$ that are the neutral elements for the addition and multiplication on $R$ respectively? Or there is any more?
Is there a way to proove that if $R$ does not have idempotents, the ring $S$ does not have idempotents either? And about nilpotents?
Let $E$ be the set of idempotent elements of $R$.
Then $S=\{f:X\to R\mid f(x)\in E,\forall x\in X\}$.
In other words, $S$ is the set of functions from $X$ to $R$ whose range is a subset of $E$.
As noted in the comments, $R$ always has $0$ as an idempotent, and if $R$ has a multiplicative identity $1$ with $1\ne 0$, then $1$ is another idempotent of $R$.
You mentioned "nilpotent elements" but this problem is about idempotent elements, not nilpotent elements. Note also that $1$ is idempotent but not nilpotent (provided $1\ne 0$).
I hope that clears up a few things, but feel free to ask for further clarification.
Let's look at a few examples . . .
Example $(1)$:$\;$Let $R=\mathbb{Z}$ and let $X=\{a,b,c\}$.
Then $E=\{0,1\}$ and $S$ is the set of functions from $X$ to $R$ such that $$ \begin{cases} f(a)\in\{0,1\}\\[4pt] f(b)\in\{0,1\}\\[4pt] f(c)\in\{0,1\}\\ \end{cases} $$ so $|S|=2^3=8$.
Example $(2)$:$\;$Let $R=\mathbb{Z_6}=\{0,1,2,3,4,5\}$ and let $X=\{a,b\}$.
Then $E=\{0,1,3,4\}$ and $S$ is the set of functions from $X$ to $R$ such that $$ \begin{cases} f(a)\in \{0,1,3,4\}\\[4pt] f(b)\in \{0,1,3,4\}\\[4pt] \end{cases} $$ so $|S|=4^2=16$.
Example $(3)$:$\;$Let $R$ be the ideal $(2)=\{0,2,4\}$ of $\mathbb{Z_6}=\{0,1,2,3,4,5\}$ and let $X=\{a,b\}$.
Then $E=\{0,4\}$ and $S$ is the set of functions from $X$ to $R$ such that $$ \begin{cases} f(a)\in \{0,4\}\\[4pt] f(b)\in \{0,4\}\\[4pt] \end{cases} $$ so $|S|=2^2=4$. Note that for this example, $R$ does not have a multiplicative identity.