Instances and parts

Everything in a place is an instance: parts, models, lights, sounds, scripts, GUI elements. This page covers making and finding instances, then the properties of each class.

Creating and destroying

CallDescription
Instance.new(className)Makes the object. Parts appear in the workspace immediately. Instance.new(class, parent) works but is easy to misuse, because every property you set afterwards is replicated one at a time.
Instance.Create(className, props)Studz addition. Makes the object, sets the properties from the table, and sets Parent last. If a property is invalid, the half-made object is removed and the error is raised.
inst:Clone()Copies the object and everything below it, with the same name, next to the original.
inst:DestroyAfter(seconds)Studz addition. Destroy after a delay, without blocking the script.
inst:Destroy()Removes the object and everything below it, and forgets their tags, attributes and listeners.
inst:ClearAllChildren()Destroys every child. A workspace keeps its scripts.
inst.Parent = nilAlso destroys the object. Studz has no limbo, so an object with no parent cannot be put back.
local coin = Instance.Create("Part", {
    Name = "Coin",
    Position = Vector3.new(0, 5, 0),
    Size = Vector3.new(1.5, 0.4, 1.5),
    Color = "gold",
    Anchored = true,
    Parent = workspace,
})

Available classes

GroupClasses
WorldPart, Model, Folder
CharactersHumanoid (a rig, or the Humanoid of one: see Rigs)
BehaviourClickDetector, Script, LocalScript, ModuleScript
EffectsPointLight, Decal, Sound
JointsWeldConstraint, Weld (see Welds)
ValuesIntValue, NumberValue, StringValue, BoolValue, Vector3Value
MessagingRemoteEvent, RemoteFunction, BindableEvent
GUIScreenGui, TextLabel, TextButton, Frame

A class name Studz does not know, and that is not a typo, makes a plain Part with a warning.

Finding instances

Children and descendants

MemberReturnsDescription
inst.ChildInstance or nilDirect child lookup by name (workspace.Baseplate, part.Weld, character.Humanoid). A real property of the object wins over a child of the same name. On containers (workspace, models, services) a missing name gives nil. On parts and other checked objects it raises an error.
inst:FindChild(name)Instance or nilChild by name.
inst:GetChild(name)InstanceStudz addition. Child by name, or an error that names the object and lists its children. Use it where a missing child is a bug.
inst:FindChildOfClass(class)Instance or nilFirst child that is that class or a subclass.
inst:AwaitChild(name, [timeout])Instance or nilYields until the child exists. Returns nil after timeout (default 5 s).
inst:Children()tableDirect children.
inst:Descendants()tableEvery object below.
workspace:GetPartBoundsInRadius(position, radius)tableEvery object within radius studs of position.

Ancestors and identity

MemberDescription
inst.NameDisplay name.
inst.ClassNameClass, read-only.
inst.ParentThe parent: workspace, a model, a folder or a part.
inst:FindAncestor(name)Search upward by name. inst:FindAncestorOfClass(class) searches upward by class.
inst:IsA(class)Whether the object is that class or a subclass.
inst:IsDescendantOf(ancestor)Ancestry check.
inst:FullName()Dot path, such as Workspace.ObstacleCourse.LavaPart.

Tags and attributes

Tags and attributes let you mark objects without extra instances.

MemberDescription
inst:AddTag(tag), :RemoveTag(tag), :HasTag(tag), :GetTags()Manage tags.
CollectionService:GetTagged(tag)Every object with the tag.
inst:SetAttribute(name, value), :GetAttribute(name), :GetAttributes()Store values on an object.

Tags and attributes live on the side that set them. They are not replicated to other machines, and they are forgotten when the object is destroyed.

Parts

A Part is a physical block, ball, cylinder or wedge.

Appearance and shape

PropertyTypeDescription
NamestringDisplay name.
SizeVector3Dimensions. Clamped to at least 0.1.
Shapestring"Block", "Ball", "Cylinder" or "Wedge".
ColorColor3Surface tint. A colour name such as "gold" or a hex string is also accepted.
Materialstring"Plastic", "Neon", "Wood", "Metal", "Slate", "Foil" and others.
Transparencynumber0 is solid, 1 is invisible.

Position and orientation

PropertyTypeDescription
CFrameCFrameWorld transform.
PositionVector3World position.
Orientation (also Rotation)Vector3Euler angles in degrees.

Setting CFrame or Position on a player's character or its HumanoidRootPart teleports the character.

Physics

PropertyTypeDescription
Anchoredbooleantrue freezes the part. false lets physics move it.
CanCollidebooleanWhether other things bump into it.
Frictionnumber0 to 2.
ElasticitynumberBounciness, 0 to 1.
LinearVelocityVector3Velocity in studs per second (unanchored parts).
AngularVelocityVector3Angular velocity.
SurfaceVelocityVector3Surface velocity. A part with this set works as a conveyor.

Part methods

MethodDescription
part:ApplyImpulse(v)Gives an unanchored part an instant push.
part:ApplyForce(v)Applies a force to an unanchored part.
part:Spin(degreesPerSecond, [axis])Rotates the part every frame. Returns a connection: :Off() stops it.
part:TweenTo(goals, seconds, [style], [direction])Animates properties. See World, tweens and effects.
part:WeldTo(other)Studz addition. Holds the part where it is now, relative to other (a part or a limb of a player's character), and returns the WeldConstraint it made. See Welds.
part:BreakWelds()Destroys every weld that joins the part. Returns how many were broken.

Welds

A weld keeps one part in place relative to another. WeldConstraint and Weld are objects you make with Instance.new (or Instance.Create). Parent them anywhere, usually inside Part1.

MemberTypeDescription
Part0part, limb or nilWhat Part1 follows. It may be a limb of a player's character (character.RightArm, character.HumanoidRootPart): the weld then follows that limb, including any pose a script gave it (see Limbs).
Part1part or nilThe part that is held. It must be a part.
C0, C1CFrameWhere the join sits on each part. Part1 is held at Part0 * C0 * C1:Inverse(). A WeldConstraint ignores what you set: it records the offset the two parts have at the moment both Part0 and Part1 are set.
EnabledbooleanA disabled weld holds nothing. Enabling a WeldConstraint records the offset again.
-- Hold a flag on top of a crate. It stays 3 studs above it however the crate moves.
local crate, flag = workspace.Crate, workspace.Flag
local weld = Instance.new("WeldConstraint")
weld.Part0 = crate
weld.Part1 = flag
weld.Parent = flag

-- The same in one call:
flag:WeldTo(crate)

-- A Weld places Part1 by C0 and C1 instead:
local hinge = Instance.new("Weld")
hinge.Part0 = crate
hinge.Part1 = flag
hinge.C0 = CFrame.new(0, 3, 0) * CFrame.Angles(0, math.rad(45), 0)

How welds behave:

  • They are held every step, after physics, on the server. A part welded to a rolling ball, to a platform a script moves, or to another welded part keeps its place. Chains work; welds that form a circle are ignored.
  • A held part is anchored while the weld holds it, so physics does not fight the weld (a part that was unanchored falls again when the weld goes). It stays solid: its collision moves with it.
  • A part is held by one weld at a time. If two welds hold it, the first one in the place wins.
  • A WeldConstraint made between parts already in place moves nothing. A Weld moves Part1 to where its C0 and C1 say on the next step.
  • A LocalScript cannot weld. Welds are made and held by the server, and the result is replicated.
  • A weld to a player's limb follows the player's position, the way they face and any pose a script gave the limb. It does not follow the built-in walk animation or a clip a script plays, which each client draws by itself.
  • Welds made by a script exist while the game runs. They are not saved with the place. Weld parts in Polycarbonate with the Weld tool or the Weld to property: those parts also follow now when a script moves what they are welded to.
  • Clone copies the welds inside a model and joins the copies to each other.

Models

MethodDescription
model:PivotTo(cf)Moves the whole model.
model:SetPrimaryPartCFrame(cf)Roblox-compatible equivalent.
model:MoveTo(pos)Moves the model to a position.

Other classes

PointLight

PropertyDescription
Brightness, Range, AngleIntensity, reach in studs, cone angle.
EnabledTurn the light on and off.

Value objects

IntValue, NumberValue, StringValue, BoolValue and Vector3Value hold one value.

MemberDescription
.ValueThe stored value.
.Changed:On(function(newValue) end)Fires with the new value.

ClickDetector

MemberDescription
MaxActivationDistanceHow far away a player can click. Default 32.
MouseClick:On(function(player) end)Fires when a player clicks the part.

For most scripts part.Clicked is simpler, because it creates the detector for you.

Decal

PropertyDescription
TextureThe picture, such as decal/123 for a Creator Store decal.
FaceWhich face of the part it covers.
Color, TransparencyTint and transparency.

Sound

MemberDescription
SoundIdThe clip: a built-in name or sound/<id> for an upload.
Volume, Speed, LoopPlayback settings.
PlayingWhether it is playing. Set it to true to play and false to stop.
MaxDistanceHow far away it can be heard.

For one-off effects use Sound.play instead of a Sound object: see World, tweens and effects.

A sound inside a part is positional: it gets quieter with distance. A sound in the Workspace plays everywhere.

GUI objects

TextLabel, TextButton and Frame make on-screen elements. Created in a server script they appear for everyone. Created in a LocalScript they appear for that player only.

PropertyDescription
Text, TextColor, TextSize, FontThe text and how it looks.
TextTransparency, ShadowTransparency, ShadowColorText fading and shadow.
Position, SizeUDim2 values.
AnchorPointVector2.
BackgroundColor, BackgroundTransparencyFill.
BorderColor, BorderWidth, CornerRadiusBorder and rounding.
Visible, ZIndexShow or hide, and stacking order.

A button's click signal is Clicked. It is a normal signal, so On returns a connection. Destroy() removes an element. GuiService:ClearAll() removes every script-made element. At most 500 GUI elements can exist at once.

local label = Instance.Create("TextLabel", {
    Text = "Welcome!",
    Position = UDim2.new(0.5, 0, 0.1, 0),
    AnchorPoint = Vector2.new(0.5, 0),
    TextSize = 28,
})

For quick messages, the ui helper is shorter: see Globals and services.