0% found this document useful (0 votes)
11 views6 pages

Roblox Lesson 11

This document covers two main topics in Roblox programming: Nested Loops and Positioning Objects using Vector3. Nested Loops allow for repetitive tasks in batches, while Vector3 is used to define the position of objects in 3D space through its X, Y, and Z coordinates. The document also provides practical examples, such as creating multi-colored cubes and simulating raining parts using nested loops.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Roblox Lesson 11

This document covers two main topics in Roblox programming: Nested Loops and Positioning Objects using Vector3. Nested Loops allow for repetitive tasks in batches, while Vector3 is used to define the position of objects in 3D space through its X, Y, and Z coordinates. The document also provides practical examples, such as creating multi-colored cubes and simulating raining parts using nested loops.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

(Roblox Lesson 11)

Learning Objectives:
1. Nested Loops
2. Positioning Objects

Chapter 1: Nested Loop


Outer Loop
Condition

- A Nested Loop is a loop within a loop, an inner


loop within the body of an outer loop.
Inner Loop
Condition
- The first iteration of the outer loop activates the
inner loop, which executes to completion. Then,
then second iteration activates the inner loop
again. This repeats until the outer loop executes
to completion.

- Nested Loops allows you to repeat tasks in


batches.
Chapter 2: Positioning Objects Using Vector3

- Physical objects in a Roblox game can be positioned in various ways, depending on your
design goals.
- The global position of an object is determined by its three position properties X, Y and Z.
- The position is based on the center of the object.
- Vector3 describes a vector in a 3D space. It supports basic component-based arithmetic
operators such as:
1. Sum
2. Subtraction
3. Multiplication
4. Division
- Some example usages of Vector3 are:
1. Position
2. Rotation
3. Size
4. Parts

X axis = Left and Right

Y axis = Up and Down

Z axis = Forward and Backwards


Z

X
Colored Cube Maker:
If you wanted to code a game where players can make multiple-colored cubes at a time, you
can use one loop to control how many batches of cubes to make, and an inner loop to control
how many cubes are made per batch.

1. In an empty baseplate file, click on the “+” button beside the Workspace and add in a new script.

2. Create a variable to calculate the total number of cubes spawned


3. Create a new function to spawn a new cube

4. Create a Nested Loop to spawn the cubes.


The outer loop will is an infinite loop.
The inner loop will spawn the cubes.

Outer
Inner
Loop
Loop

5. Your overall code should look like this


Raining blocks:
Using the concept that we learnt from Nested Loops above, try to create raining parts falling
from the sky!
The parts should be all of different colors.

1. In an empty baseplate file, click on the “+” button beside the Workspace and add in a new script.

2. Create a new function to spawn a new part


3. Create a Nested Loop to spawn the rain.
The outer loop will change the color of the rain.
The inner loop will spawn the rain.

4. Your overall code should look like this

You might also like