Roblox Objects
Lua Roblox Part
Working with Parts
Lua Roblox Part manipulates 3D objects with Position and Size.
Understanding the Part Object
In Roblox, a Part is a fundamental building block for creating 3D objects. It represents a physical object in the game world and can be manipulated through various properties, such as Position and Size.
Setting the Position of a Part
The Position property of a Part determines its location in the 3D world. You can set this property using a Vector3 value, which consists of X, Y, and Z coordinates.
local part = Instance.new('Part')
part.Position = Vector3.new(0, 10, 0)
part.Parent = workspace
Modifying the Size of a Part
The Size property controls the dimensions of a Part. This property also uses a Vector3 value to specify width (X), height (Y), and depth (Z).
local part = Instance.new('Part')
part.Size = Vector3.new(5, 1, 5)
part.Parent = workspace
Combining Position and Size
By combining both Position and Size, you can precisely control the placement and dimensions of objects in your game.
local part = Instance.new('Part')
part.Position = Vector3.new(10, 5, 10)
part.Size = Vector3.new(10, 2, 10)
part.Parent = workspace
Practical Application
Use these properties to create platforms, obstacles, or any other objects you can imagine. For example, a simple platform can be created with a specific size and position:
local platform = Instance.new('Part')
platform.Position = Vector3.new(0, 10, 0)
platform.Size = Vector3.new(20, 1, 20)
platform.Anchored = true
platform.Parent = workspace
In this example, we also set the Anchored property to true
to prevent the platform from moving due to physics.
Roblox Objects
- Previous
- Instance Properties
- Next
- Model