In the above sample you'd have to tweak it in order to accommodate to your needs, however, there might be a simpler solution through the use of our Flipbook function, as per the example below:
Even though its supposed to animate the transition, you can set the Time parameter to 0, and be sure to have your texture's 'Wrap Mode' set to 'Repeat'. In your particular case, you'll also have to pass the random number to the Start Frame Input.
You can also edit this function in order to see how we've set it up and, if you prefer, create your own simplified custom function.