Anchoring a Part Using Code

Anchoring a Part Using Code

Mar 30 2021, 5:20 AM PST


Create a part that stays stationary (anchored in place).


Use the Instance.new() function, the Anchored property, and the Parent property.

local part = Instance.new("Part")
part.Anchored = true
part.Parent = game.Workspace


To create an instance of a Roblox object (the things that can be manipulated in your game, like a block), you must use the Instance.new() function. This function is used to create all Roblox objects. It returns the object which is then assigned to the variable part.

There are two properties (characteristics of the object) which are changed afterwards:

  1. The goal states that this part should be stationary, meaning that it should not fall to the ground. In order to do so, the Anchored property should be set to true.

  2. In order for a part to appear in the game, its Parent property must be set to a directory called Workspace. This can be accessed by writing game.Workspace or simply workspace.

  • anchor
  • part