Q:

Checking if a number is Polygonal

Polygonal numbers are of the form $\cfrac{n^2(s-2)-n(s-4)}{2}$, where $s$ is the number of sides of the polygon and $n$ is to say which one it is (the $n^{th}$ $s$-gonal number)
So my question is, how can you tell if a number is polygonal, and if it is, which $n,p$ plugged into the formula get you the number. Basically is there some kind of check if a number is polygonal?

A:

This is probably more complicated than you are hoping for, but it at least restates the problem by breaking it into two smaller problems.
Suppose you are given some number $A$ and wish to know whether it is equal to the given formula for some $n$ and $s$.  If so, then we would have
$$\frac{s-2}{2}n^2 - \frac{s-4}{2}n = A$$
which, after some very slight rewriting, is
$$\frac{s-2}{2}n^2 + \frac{4-s}{2}n - A=0$$
Now by the quadratic formula, we have
$$n = \frac{\frac{s-4}{2}\pm \sqrt{\left(\frac{4-s}{2}\right)^2+2A(s-2)}  }{s-2}$$
This can be simplified somewhat:
$$n = \frac{s-4\pm \sqrt{\left(4-s\right)^2+8A(s-2)}  }{2s-4}$$
Now let's look back.  If $A$ is a polygonal number then the above expression must be a natural number, which means at the very least that the expression under the radical must be a perfect square.  So we have a necessary condition:

Given $A$, is there some $s$ such that $(4-s)^2+8A(s-2)$ is a perfect square?

We can massage this a bit more:  It is equivalent to

Given $A$, is there some $s$ such that $s^2+(8A-8)s+(16-16A)$ is a perfect square?

Assuming you have answered that question in the affirmative, and have found some number $B$ with the property that $s^2+(8A-8)s+(16-16A)=B^2$, you can then take that result back to the earlier formula for $n$, and ask:

Is $$n=\frac{s-4 \pm B}{2s-4}$$ a whole number?

This can be slightly massaged, as well:  Since $\frac{s-4 \pm B}{2s-4} = \frac{2s-4 - s \pm B}{2s-4} = 1 - \frac{s\pm B}{2s-4}$, it is equivalent to:

Is $s \pm B$ a multiple of $2s-4$? 

So, in summary:  If you can find some number $s$ such that $(4-s)^2+8A(s-2)$ is a perfect square, say $B^2$, and if $s \pm B$ is a multiple of $2s-4$, then the number is polygonal.

