1.8 Parts

Without parts to populate your game, it wouldn’t make for a very interesting map.

BaseParts comprise the majority of the physical objects you encounter in the game world. Often generically just referred to as ‘parts,’ BaseParts give an object its physical representation and numerous related properties and functionality.

BaseParts, however, are not an object you can add to the game world. Instead, BasePart is a class that acts as a root component which other classes of parts implement by building on top of, adding additional data and behavior required for that class of parts. This is known as a ‘base class.’ The new classes built from the base class is a ‘derived class.’

The two common derived classes of BaseParts that you will encounter are the Part and the MeshPart.


Parts

With a capital ‘P.’ These are parts that are built-in to Roblox and have predefined shapes. Said shapes are the Block, Ball, Wedge, Corner Wedge, and Cylinder. Sometimes you might also hear them be referred to a ‘primitives.’

You can find these parts in the ‘Home’ or “Model’ tabs under the ‘Part’ tool. Clicking the tool will add a part where the camera is facing.

In the properties window, you can set the color, material, transparency, mass, and more. The ‘Anchored’ sets whether a part is locked in place or can move as a result of physics.

Position and size can be directly set in properties. Or you could also use the move, scale, or rotate tools to manipulate a part. Find those under the ‘Home’ and ‘Model’ tabs in the toolbar or via the shortcut 2, 3, 4 for move, scale, and rotate respectively.

Every part has an orientation determined by its front, up, and right direction. These are in the part’s negative-Z, positive-X, and positive-Y direction respectively and make up the part’s ‘local axis.’

This is always relative to the part, regardless of the direction the part is facing. You can view a part’s orientation by right-clicking on it and toggling the ‘Show/Hide Orientation Indicator.’

Each axis is represented by a primary color. Red for X. Green for Y. And blue for Z.

The car on the left shows the local axis, denoted by the ‘L.’ The one on the right is aligned with the global axis. Pressing Ctrl+L will toggle Move/Scale/Rotate between the local and global axis.


Solid Modeling

Because the primitive shapes are built-in, they are generally the best optimized.

But the world is not made up of just spheres and cylinders and cubes. And while the wedge shapes and the block shape can be resized for different proportions, the ball and the cylinder cannot and must always maintain their spherical or cylindrical shape.

One of the functionalities of Parts is the ability to create new shapes using operations that add, subtract, or combine overlap of primitives.

Under the ‘Solid Modeling‘ section, you will the tools for performing these operations.

As an example, place a block on the map and set it’s size to (12, 1, 12). This will make the part 12 studs in the X-Z dimension and 1 stud in the Y.

Then create a cylinder part and set its dimension to (2, 10, 10) and place it at the same position as the block. You may need to rotate it to get it to face the proper direction

You can copy a part’s exact position by selecting and copying the value from the properties window for the block. And then paste that value into the same property on the other part.

With both parts overlapping, select the cylinder and click the ‘Negate’ button found in ‘Model->Solid Modeling’ which will turn the cylinder into a semi-transparent red color.

This means that the part is now a “negative” part and will subtract its shape from any shape it overlaps.

Select both the block and the cylinder then click on the ‘Union’ button. This will create a hole into the block in the shape of the cylinder.

By performing solid modeling operations with the use of primitive shapes, it’s possible to create much more complex shapes that the primitive shapes cannot account for.


MeshPart

But what if you need an even more detailed shape. What if you need to create something like this?

For more complex shapes, you will need to use a ‘MeshPart.’

For MeshParts, a 3D model needs to be created using an external 3D modelling program such as Autodesk Maya or Blender and then exported as a .fbx or .obj file.

That model is uploaded to your Roblox account and the ‘asset ID’ can then be used to set the shape of the MeshPart.

Because the mesh does not contain data about how the surface of the part should look, a ‘texture’ file will also need to be uploaded.

Maya and Blender are outside the scope of this series but lets take a look at how you would add a mesh once you have the asset ID.

In the explorer, hover over the workspace icon and click the ‘+’ button to add an object. To the right of the textbox, click the white rectangle to expand the object browser. Find ‘MeshPart’ and click on that.

The part that Roblox inserts will look like just a normal block but if you select the part, the properties window will show that this is a MeshPart.

Now look for the property labeled “MeshId” and paste this number into the value field:

909114861

And then under the ‘TextureID’ enter this number:

909114866


The Toolbox

In the Toolbox window, you can find models, audio, images and more to add to you game.

Even if you don’t create your own 3D models, you can still find useful meshes that Roblox or other members have uploaded, free to use. If the window isn’t visible, enable it under the View tab.

A word of caution. Although most items in the toolbox are typically safe to use, occasionally you will run into some items that have pre-loaded scripts intended to spam or even exploit your game.

Roblox Studio will notify you to review the scripts if it detects any. Because users can review toolbox models, pay attention to their ratings and if you still aren’t sure, find a different model or delete the scripts within it.


Models

Parts by themselves are not very interesting. When we want a part to do something interesting, we might give it sounds, or scripted behavior, or maybe as a collection with other parts.

This can get quite complicated quickly so it is useful to collect all of the components together and put them into a ‘Model.’ In addition to organizing all relevant components together, Models also provide some extended the functionality to the collection.

If you launch a game and highlight your character in the Explorer, you can see that the character is a model consisting of various components.