Roblox Vector3 Explained Visually

So what is a Vector3 in Roblox scripting?

In this article, I’ll provide you with an answer.

And along the way, I’ll provide visual diagrams to really help you understand what Vector3s are in Roblox scripting.

What is a Vector3?

A Vector3 is basically a set of 3 numbers, like (5, 5, 5).

One way Vector3s are used is to represent how large something is.

Using a Vector3 for an Object’s Size

A Part in Roblox.

See this cube?

If I asked you “how large is it?”, I would expect you to tell me its height, width, and length.

That is, I would expect you to say something like “that cube is 5 studs wide, 5 studs tall, and 5 studs long.”

What is a Vector3 in Roblox scripting?

In Roblox scripting, we can convey this information by using a Vector3.

This is the exact same as saying “Set the cube’s Size to 5 studs wide, 5 studs tall, and 5 studs long.”

The difference is that instead of saying all of those unnecessary words, we condensed it down into 3 numbers: Vector3.new(5, 5, 5).

Now, what about this Part?

A Part in Roblox with a Size of a Vector3 that corresponds to 10, 3, 5.

It’s 10 studs wide, 3 studs tall, and 5 studs long.

We can once again elegantly represent that information into 3 numbers: A Vector3!

Here, we’re telling Roblox “Create a Part, and put it inside of Workspace.”

Then, we’re telling Roblox to “Give the Part a width of 10, a height of 4, and a length of 3.”

Easy, right?

Using a Roblox Vector3 with an Object’s Position

We can also use a Vector3 to manipulate an object’s position.

Let’s say I’m temporarily blind and you’re trying to describe where this Part is to me.

A rectangular shaped Part.

How will you describe it to me?

Would you say “it’s on the Baseplate”?

You’re right. It is. I would be able to understand.

But what if there are 2 parts?

A green part and a red part next to each other. I use this image to explain what a vector3 is in Roblox scripting.

And I want to know exactly where the green Part is. And I want to know exactly where the red Part is.

You’d have to use exact numbers to give me that information.

That’s where Vector3s in Roblox scripting come in!

Remember that a Vector3 is just 3 numbers.

Every object in 3D space can move in 3 different directions: X, Y, and Z.

A black part in Roblox. I use this image to explain what a vector3 is in Roblox scripting.

The red arrow represents the X direction (left and right).

The blue arrow represents the Z direction (forward and backward).

The green arrow represents the Y direction (up and down)

The Part is currently located at (0, 6, 0).

In a Vector3:

  • The first number is the X direction (left and right)
  • The second number is the Y direction (up and down)
  • The third number is the Z direction (forward and backward)

The Part being located at (0, 6, 0) means that it’s 0 on the X direction, 6 on the Y direction, and 0 on the Z direction.

In particular, this means that the Part is located 6 studs up.

A black part that is Vector3.new(0, 6, 0) away from the ground.

What if We Wanted the Part to Go Up Higher?

Now, what if we wanted this Part to go up higher?

Say, we wanted this Part’s Position to be 30 studs in the Y (up) direction.

Then, we’d just have to set the Part’s Position to Vector3.new(0, 30, 0)

This means that:

  • The Part is 0 on the X-direction (left and right)
  • The Part is 30 on the Y-direction (30 studs up)
  • The Part is 0 on the Z-direction (forward and backward)

In other words, this Part is located 30 studs above 0.

And here’s what it would look like:

A Part that is 30 studs on the y axis of the Vector3 away from the ground.

What if I wanted the Part to stay at 30 studs upward, but also be 10 Studs rightward?

Then, it would have to be at the Position Vector3.new(10, 30, 0)

  • 10 studs rightward
  • 30 studs upward
  • 0 studs forward
A Part that is 30 studs above the ground and 10 studs to the right of the ground. This is represented by Vector3.new(10, 30, 0)

In the picture, the 10 studs rightward is represented by the red lines, and the 30 studs upward is represented by the green lines.

Now, a Vector3 can also be thought of as an invisible arrow.

if we draw an arrow from the beginning of the red line to the Part, we can see the physical Vector3.

There is the Vector3 itself!

That’s the answer to what a Vector3 is in Roblox scripting: it’s that purple arrow.

The Origin Vector3 in Roblox Scripting

What if we had a Vector3 that was 0 on the X, 0 on the Y, and 0 on the Z?

That type of Vector3 has a special name. It’s called the origin, or the zero vector.

If we set our Part’s Position to the origin, we get this.

This Part has a Position of Vector3.new(0, 0, 0).

When thinking about Vector3s as arrows, we have to consider that the arrow always begins at the origin and points to the Part.

This Part has a Position of Vector3.new(-18, 8, -11).

This means:

  • It’s 18 studs to the left of the origin (A negative X means it’s going left)
  • It’s 8 studs above the origin
  • It’s 11 studs behind the origin (A negative Z means it’s going backwards)

Vector3 – Magnitude

What if we wanted to know the size of the arrow itself?

In here, what if we wanted to know the length of the white arrow?

That’s where Vector3 Magnitude comes into play.

To figure out the length of the Vector3 arrow itself, we can use the Magnitude property of Vector3s:

And in this case, Roblox will give us 22.56102752685547.

This means that if you were to measure the size of the Vector3 arrow itself, it would be 22.56 studs long.

(Advanced Bonus) How Does Roblox Calculate Vector3 Magnitude?

Okay, I guess this is kind of a fun fact, but, behind the scenes, when you do this. Roblox basically uses a 3D version of the Pythagorean theorem:

d=\sqrt{x^2+y^2+z^2}

Where x is the first number in the Vector3 (the left to right).

y is the second number in the Vector3 (the up and down).

z is the third number in the Vector3 (the forward and backward).

In essence, you can create your own Vector3 magnitude function:

Enhance Your Scripting with my Book

If you enjoyed this article and you like the way I explain things, make sure to check out my Beginner’s Guide to Roblox Scripting book.

kushal Avatar

About the author

Subscribe to Kushal Writes

Awesome tips for game development, computer science, and life lessons to help you succeed — straight to your email for FREE!

Join 50+ readers

    By submitting this form, you’ll be signed up to my free newsletter. You can unsubscribe at any time.

    Learn Roblox Scripting

    Get the Beginner’s Guide to Roblox Scripting Book and learn Roblox scripting in an easy to understand way.



    Search Kushal Writes