Hi Jody,
That slider is already "attached" to the variable n, you can see it in the list of defined variables by pressing VAR.
The issue is that the regular polygon tool doesn't take a variable input to set the number of sides, you set that by swiping left/right after defining center & radius. [Of course there is a variable "under the hood" but not available to user].
I have an old file where I created partial regular polygons by dividing 360 by n and rotating a segment that many degrees around a center point. Students recorded measure of central angle, interior angle, exterior angle, and number of sides.
Attaching the tns and pdf here if it is helpful.
Best, Karen