---
title: How to Build a Random Spinner in Storyline
description: Learn how to build a random spinner solution that combines Storyline states, variables, and triggers. eLearning developers will appreciate this tutorial.
image: https://blog.elblearning.com/hubfs/How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline_Blog%20Featured%20Image%20800x500.png
---

[![ELB-Learning_Logo_ColorRGB-white-text-1](https://blog.elblearning.com/hubfs/ELB-Learning_Logo_ColorRGB-white-text-1.png) ](https://elblearning.com/)

![How to Build a Random Spinner in Storyline_Blog Featured Image 800x500](https://blog.elblearning.com/hubfs/How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline_Blog%20Featured%20Image%20800x500.png)

# How to Build a Random Spinner in Storyline

 by [James Kingsley](https://blog.elblearning.com/author/james-kingsley) | Oct 1, 2019

A few days ago I noticed a [discussion in the Articulate Storyline forum](https://community.articulate.com/discussions/articulate-storyline/spin-the-wheel) about creating a random spinner for a game. I took up the challenge and created a solution that combines Storyline states, variables, and triggers. Of course there is some JavaScript sprinkled in there as well :-)

## How to Build a Random Spinner in Storyline

Check out the demo here before reading on so you can see what the end result was.

[![View Demo](https://no-cache.hubspot.com/cta/default/5108583/f5a1d6be-1126-4f30-9dcf-c7013a6daabe.png)](https://cta-redirect.hubspot.com/cta/redirect/5108583/f5a1d6be-1126-4f30-9dcf-c7013a6daabe)

### The goal was to:

- Create a spinner that the learner can trigger.
- It will land on a random number.
- It will not land on the same number twice.

### My solution was to use:

- Pie segments.
- A Storyline knob.
- Storyline variables for each segment.
- Triggers to change the segment's state when the variable changes.
- JavaScript that:

### Check out the video below to see how it all works together.

 

var currentSlice = 0;

var spinLimit = 5;

var spinCount = 0;

var slices = [1, 2, 3, 4, 5];

var targetSlice = 0;

var spinning;

 

function getNextSlice() {

return slices.splice(Math.floor(Math.random() * slices.length), 1)[0];

}

 

function spinWheel() {

  var p = GetPlayer();

  p.SetVar("pieVisited_" + targetSlice, true);

  targetSlice = getNextSlice();

  if (!targetSlice) return;

  spinning = setInterval(function() {

    currentSlice++;

    spinCount++;

    p.SetVar("Dial1", currentSlice);

    if (currentSlice > 5) currentSlice = 0;

    if (spinCount >= spinLimit && currentSlice === targetSlice) {

      clearInterval(spinning);

      p.SetVar("pieSelected_" + targetSlice, true);

      currentSlice = 0;

      spinCount = 0;

    }

  }, 250);

}

 

# Want more Storyline resources?

Sign up for a free 7-day trial of the eLearning Brothers Asset Library and gain access to tons of Storyline course starters, stock assets, cutout people, and more.

[![Free Trial](https://no-cache.hubspot.com/cta/default/5108583/e83b2b24-faec-4b25-ae34-88a4978db4d0.png)](https://cta-redirect.hubspot.com/cta/redirect/5108583/e83b2b24-faec-4b25-ae34-88a4978db4d0)

 

---

**About the Author**

![James Kingsley headshot](https://lh5.googleusercontent.com/EegbqTLfxrxYX52PK9WFtjz85Ynrb_o5d3eHVEwomi0DO9kmvKZx1get7ePk6zTv_gBdiOE4ITbpVfl9OXxsz_mk1yF7qU76DLjuyoPDts709ljD31xvWBG8_rdzS8W09L4FOUiT)

James Kingsley has worked in the eLearning Industry for over 16 years. He has won several awards for combining technologies to produce better eLearning. James is a Solver of Complex eLearning Puzzles, Founder of [CoursePortfolios.com](https://courseportfolios.com/), and the Co-Founder of [ReviewMyElearning.com](https://www.reviewmyelearning.com/). You can follow him on [Twitter](https://twitter.com/onEnterFrame) or connect with him on [LinkedIn](https://www.linkedin.com/in/jameskingsley) for additional tips and examples.

 

 

 

 

[eLearning-](https://blog.elblearning.com/tag/elearning), [instructional design-](https://blog.elblearning.com/tag/instructional-design), [Articulate Storyline Resources-](https://blog.elblearning.com/tag/articulate-storyline), [how to-](https://blog.elblearning.com/tag/how-to), [eLearning Development Tips-](https://blog.elblearning.com/tag/elearning-development-tips)

### Related Posts

[![The Secret to Humanized Instructional Story Design (with No Fluff)](https://blog.elblearning.com/hs-fs/hubfs/Recap%207-31-2025_Blog%20Featured%20Image%20800x500.png?width=388&name=Recap%207-31-2025_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/how-story-based-learning-transforms-training-insights-from-instructional-story-design)

[The Secret to Humanized Instructional Story Design (with No Fluff)](https://blog.elblearning.com/how-story-based-learning-transforms-training-insights-from-instructional-story-design)

[![Improving L&D with AI Work Augmentation](https://blog.elblearning.com/hs-fs/hubfs/Improving%20L%26D%20with%20AI%20Work%20Augmentation_Blog%20Featured%20Image%20800x500.png?width=388&name=Improving%20L&D%20with%20AI%20Work%20Augmentation_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/improving-ld-with-ai-work-augmentation)

[Improving L&D with AI Work Augmentation](https://blog.elblearning.com/improving-ld-with-ai-work-augmentation)

[![Leaving the Classroom: From Teaching to Instructional Design](https://blog.elblearning.com/hs-fs/hubfs/Leaving%20the%20Classroom-%20From%20Teaching%20to%20Instructional%20Design_Blog%20Featured%20Image%20700x306-1.png?width=388&name=Leaving%20the%20Classroom-%20From%20Teaching%20to%20Instructional%20Design_Blog%20Featured%20Image%20700x306-1.png) ](https://blog.elblearning.com/leaving-the-classroom-from-teaching-to-instructional-design)

[Leaving the Classroom: From Teaching to Instructional Design](https://blog.elblearning.com/leaving-the-classroom-from-teaching-to-instructional-design)

[![A Brief History of Instructional Design](https://blog.elblearning.com/hs-fs/hubfs/A%20Brief%20History%20of%20Instructional%20Design_Blog%20Featured%20Image%20800x500.png?width=388&name=A%20Brief%20History%20of%20Instructional%20Design_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/a-brief-history-of-instructional-design)

[A Brief History of Instructional Design](https://blog.elblearning.com/a-brief-history-of-instructional-design)

[![Why We're Mad for Microlearning](https://blog.elblearning.com/hs-fs/hubfs/Why%20Were%20Mad%20for%20Microlearning_Blog%20Featured%20Image%20800x500.png?width=388&name=Why%20Were%20Mad%20for%20Microlearning_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/why-were-mad-for-microlearning)

[Why We're Mad for Microlearning](https://blog.elblearning.com/why-were-mad-for-microlearning)

[![What Is Scrap Learning and How Much Is It Costing Your L&D Department?](https://blog.elblearning.com/hs-fs/hubfs/What%20Is%20Scrap%20Learning%20and%20How%20Much%20Is%20It%20Costing%20Your%20L%26D%20Department__Blog%20Featured%20Image%20800x500.png?width=388&name=What%20Is%20Scrap%20Learning%20and%20How%20Much%20Is%20It%20Costing%20Your%20L&D%20Department__Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/what-is-scrap-learning-and-how-much-is-it-costing-your-ld-department)

[What Is Scrap Learning and How Much Is It Costing Your L&D Department?](https://blog.elblearning.com/what-is-scrap-learning-and-how-much-is-it-costing-your-ld-department)

- [**
  
  Facebook
  
  
  
  ](http://www.facebook.com/sharer.php?u=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline%2F&t=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline)
- [**
  
  Twitter
  
  
  
  ](http://twitter.com/share?text=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline&url=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline)
- [**
  
  Pinterest
  
  
  
  ](http://pinterest.com/pin/create/button/?url=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline&media=https://cdn2.hubspot.net/hubfs/5108583/How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline_Blog%20Featured%20Image%20800x500.png&description=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline)
- [**
  
  LinkedIn
  
  
  
  ](http://www.linkedin.com/shareArticle?mini=true&url=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline%2F&title=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline)
- [**
  
  Gmail
  
  
  
  ](https://mail.google.com/mail/u/0/?view=cm&fs=1&su=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline&body=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline%2F&ui=2&tf=1)
- [**
  
  reddit
  
  
  
  ](http://www.reddit.com/submit?url=https://blog.elblearning.com/how-to-build-a-random-spinner-in-storyline%2F&title=How%20to%20Build%20a%20Random%20Spinner%20in%20Storyline)

© 2025 ELB Learning. All rights reserved.  | [ Terms of Use](https://www.elblearning.com/legal/terms-of-use)  |  [Privacy Policy ](https://www.elblearning.com/legal/privacy-policy)|  [Legal Notices](https://www.elblearning.com/legal/legal-notices)