Make the Light Repeat

Right now, the light only turns on and off once. To make the lamp continuously glow on and off, the fors loops will be placed inside a repeating while loop.

  1. Place both for loops inside a while loop. Indent the for loops to make them easier to tell apart from the while loop.
Keep Code Indented

To make your code easier to read, check that your code is indented like the block above. To indent your code:

  • Tab to move a line forward.
  • Ctrl / Cmd + Tab to move a line back.

  1. Run the game to see the light turn brighten and dim forever.

If you can’t see the brightness change over time:

  • Make sure that light.Brightness = currentBrightness is between the do and end of your for loop.
  • Check that timeChange is at least 1 or higher. Smaller numbers will make the brightness change faster, but be harder to see over time.
  • Check that the first line of your for loop has two total commas separating the control variable, end value, and increment value.

With the light created, you can copy both GlowScript and PointLight into any other part to make more lamps in your world.

Finished Project Sample

Project File

Download the finished project here.

Finished Script