12 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

Path2D

Inherits from: GuiBase → Instance → Object

Path2D is a UI instance that represents a 2D spline. It can be placed under any GuiObject and be edited directly in the viewport using built‑in tooling. Path2D stores control points and exposes methods to sample positions along the curve, enabling curved UI layouts, path‑based animations, and interactive tools like graph editors and visual effects.

See the 2D paths guide for more information and usage examples.

Inherits from: GuiBase

Memory category: Instances

Properties

NameType / ReturnsDescription
Path2D.ClosedbooleanConnects the first and last control points when enabled.
Path2D.Color3Color3Determines the color of the Path2D.
Path2D.SelectedControlPointintIndex of the currently selected Path2DControlPoint.
Path2D.SelectedControlPointDataPath2DControlPointPath2DControlPoint data type representing the currently selected control point.
Path2D.ThicknessfloatDetermines how thick the Path2D path is.
Path2D.VisiblebooleanDetermines if the Path2D path is rendered or not.
Path2D.ZIndexintDetermines the order in which a Path2D path renders relative to other GUIs.

Inherited from Instance

NameType / ReturnsDescription
Instance.ArchivablebooleanDetermines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published.
Instance.archivableboolean
Instance.CapabilitiesSecurityCapabilitiesThe set of capabilities allowed to be used for scripts inside this container.
Instance.IsInSandboxbooleanIndicates whether the instance is inside a sandboxed container.
Instance.NamestringA non-unique identifier of the Instance.
Instance.ParentInstanceDetermines the hierarchical parent of the Instance.
Instance.PredictionModePredictionModeReflects the client-side prediction mode applied to the instance under server-authoritative physics.
Instance.RobloxLockedbooleanA deprecated property that used to protect CoreGui objects.
Instance.SandboxedbooleanWhen enabled, the instance can only access abilities in its Capabilities list.
Instance.UniqueIdUniqueIdA unique identifier for the instance.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring

Path2D.Closed

When set to true, the path forms a closed loop by connecting the last control point back to the first. The closure only takes effect when the path has at least 3 control points. Defaults to false.

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Path2D.Color3

Determines the stroke color used to render the Path2D. Defaults to [0, 0, 0] (black). A child UIGradient can override the solid color with a gradient fill.

FieldValue
typeColor3
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Path2D.SelectedControlPoint

The 1-based index of the currently selected control point. Defaults to 1 and is clamped to the range [1, number of control points]. Changing this value updates Path2D.SelectedControlPointData to reflect the control point at the new index.

FieldValue
typeint
tags["NotReplicated"]
security{"read":"RobloxScriptSecurity","write":"RobloxScriptSecurity"}
thread safetyReadSafe
categoryControl Points
serialization{"can_load":true,"can_save":false}
capabilities["UI"]

Path2D.SelectedControlPointData

A read-only computed property that returns the Path2DControlPoint at the index specified by Path2D.SelectedControlPoint. If the path has no control points, returns a default-constructed Path2DControlPoint (position and tangents all at {0, 0, 0, 0}).

FieldValue
typePath2DControlPoint
tags["NotReplicated"]
security{"read":"RobloxScriptSecurity","write":"RobloxScriptSecurity"}
thread safetyReadSafe
categoryControl Points
serialization{"can_load":true,"can_save":false}
capabilities["UI"]

Path2D.Thickness

Determines the stroke width of the Path2D in pixels. Defaults to 1 and is clamped to the range [0, 100].

FieldValue
typefloat
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Path2D.Visible

Determines if the Path2D path is rendered or not. When false, the path will not render. However, any modifications to the control points will update correctly, ensuring that querying data will have the correct info.

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Path2D.ZIndex

Determines the order in which a Path2D path renders relative to other GUIs. Works the same as GuiObject.ZIndex but does not interact with layout order in any way.

FieldValue
typeint
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Methods

NameType / ReturnsDescription
Path2D:GetBoundingRectRectReturns the bounding size for the Path2D.
Path2D:GetControlPointPath2DControlPointReturns the Path2DControlPoint for a given index.
Path2D:GetControlPointsArrayReturns all the Path2DControlPoints for the Path2D.
Path2D:GetLengthfloatReturns the length of the Path2D.
Path2D:GetMaxControlPointsintReturns the maximum allowed number of control points.
Path2D:GetPositionOnCurveUDim2Returns the position at a given value in parameter space.
Path2D:GetPositionOnCurveArcLengthUDim2Returns the position at a given value in arc length space.
Path2D:GetTangentOnCurveVector2Returns the tangent at a given value in parameter space.
Path2D:GetTangentOnCurveArcLengthVector2Returns the tangent at a given value in arc length space.
Path2D:InsertControlPoint()Inserts a new control point at a given index.
Path2D:RemoveControlPoint()Removes a control at the given index.
Path2D:SetControlPoints()Sets all the control points to the specified array, replacing all existing points with new ones.
Path2D:UpdateControlPoint()Updates a control point at the given index.

Inherited from Instance

NameType / ReturnsDescription
Instance:AddTag()Applies a tag to the instance.
Instance:childrenInstancesReturns an array of the object's children.
Instance:ClearAllChildren()This method destroys all of an instance's children.
Instance:CloneInstanceCreate a copy of an instance and all its descendants, ignoring instances that are not Archivable.
Instance:cloneInstance
Instance:Destroy()Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children.
Instance:destroy()
Instance:FindFirstAncestorInstance?Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
Instance:FindFirstAncestorOfClassInstance?Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className.
Instance:FindFirstAncestorWhichIsAInstance?Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstChildInstance?Returns the first child of the Instance found with the given name.
Instance:findFirstChildInstance
Instance:FindFirstChildOfClassInstance?Returns the first child of the Instance whose ClassName is equal to the given class name.
Instance:FindFirstChildWhichIsAInstance?Returns the first child of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstDescendantInstance?Returns the first descendant found with the given Instance.Name.
Instance:GetActorActor?Returns the Actor associated with the Instance, if any.
Instance:GetAttributeVariantReturns the value which has been assigned to the given attribute name.
Instance:GetAttributeChangedSignalRBXScriptSignalReturns an event that fires when the given attribute changes.
Instance:GetAttributesDictionaryReturns a dictionary of the instance's attributes.
Instance:GetChildrenInstancesReturns an array containing all of the instance's children.
Instance:getChildrenInstances
Instance:GetDebugIdstringReturns a coded string of the debug ID used internally by Roblox.
Instance:GetDescendantsInstancesReturns an array containing all of the descendants of the instance.
Instance:GetFullNamestringReturns a string describing the instance's ancestry.
Instance:GetStyledVariantReturns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified.
Instance:GetStyledPropertyChangedSignalRBXScriptSignalReturns an event that fires when the given style property changes on the instance.
Instance:GetTagsArrayGets an array of all tags applied to the instance.
Instance:HasTagbooleanCheck whether the instance has a given tag.
Instance:IsAncestorOfbooleanReturns true if an Instance is an ancestor of the given descendant.
Instance:IsDescendantOfbooleanReturns true if an Instance is a descendant of the given ancestor.
Instance:isDescendantOfboolean
Instance:IsPropertyModifiedbooleanReturns true if the value stored in the specified property is not equal to the code-instantiated default.
Instance:QueryDescendantsInstancesReturns an array containing all descendants of the instance that match the selector string.
Instance:Remove()Sets the object's Parent to nil, and does the same for all its descendants.
Instance:remove()
Instance:RemoveTag()Removes a tag from the instance.
Instance:ResetPropertyToDefault()Resets a property to its default value.
Instance:SetAttribute()Sets the attribute with the given name to the given value.
Instance:WaitForChildInstanceReturns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Inherited from Object

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

Path2D:GetBoundingRect

Returns the Rect bounding size for the Path2D. This is computed based on the control points and is not modifiable outside of changing the control point data.

Returns

TypeDescription
RectThe Rect bounding box that encloses the path, expanded by its rendered thickness.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetControlPoint

Returns the Path2DControlPoint for a given index. If the index is out of bounds, this method will throw an error.

Parameters

NameTypeDefaultDescription
indexintThe 1-based index of the control point to return.

Returns

TypeDescription
Path2DControlPointThe control point at the given index.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetControlPoints

Returns a table of all the Path2DControlPoints for the Path2D.

Returns

TypeDescription
ArrayTable of all the Path2DControlPoints.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetLength

Returns the length of the Path2D. This function can be expensive if called too frequently.

Returns

TypeDescription
floatThe total length of the path.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetMaxControlPoints

Returns 100, the hard upper limit on the number of control points a Path2D can contain. Attempting to add points beyond this limit via Path2D:InsertControlPoint() or Path2D:SetControlPoints() throws an error.

Returns

TypeDescription
intThe maximum number of control points a Path2D supports.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetPositionOnCurve

Returns the 2D UDim2 position at a given t value between 0 and 1 (inclusive), representing the parameter space result of querying the spline. The values will be more tightly packed near bends and wider apart in straighter segments; see GetPositionOnCurveArcLength() for even spacing results.

Throws an error if the Path2D has less than two control points.

Parameters

NameTypeDefaultDescription
tfloatThe value to query the Path2D at.

Returns

TypeDescription
UDim2The position in parameter space.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetPositionOnCurveArcLength

Returns the 2D UDim2 position at a given t value between 0 and 1 (inclusive), representing the arc length space result of querying the spline. The values will be evenly spaced along the spline; see GetPositionOnCurve() for parameter spacing results.

Throws an error if the Path2D has less than two control points.

Parameters

NameTypeDefaultDescription
tfloatThe value to query the Path2D at.

Returns

TypeDescription
UDim2The position in arc length space.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetTangentOnCurve

Returns the tangent at a given t value in parameter space where t is a value between 0 and 1 (inclusive). Throws an error if the Path2D has less than two control points.

Parameters

NameTypeDefaultDescription
tfloatThe value to query the Path2D at.

Returns

TypeDescription
Vector2The tangent in parameter space.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:GetTangentOnCurveArcLength

Returns the tangent at a given t value in arc length space where t is a value between 0 and 1 (inclusive). Throws an error if the Path2D has less than two control points.

Parameters

NameTypeDefaultDescription
tfloatThe value to query the Path2D at.

Returns

TypeDescription
Vector2The tangent in arc length space.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:InsertControlPoint

Inserts a new Path2DControlPoint at a given index. Throws a warning if the index is out of bounds or if you're trying to add control points past the limit of 50.

Parameters

NameTypeDefaultDescription
indexintThe index to insert at.
pointPath2DControlPointThe control point to insert.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:RemoveControlPoint

Removes a control point at the given index. Throws a warning if the index is out of bounds.

Parameters

NameTypeDefaultDescription
indexintThe index to remove at.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:SetControlPoints

Sets all the control points to the specified array, replacing all existing points with new ones. Throws a warning if there are more than 50 points in the controlPoints array.

Parameters

NameTypeDefaultDescription
controlPointsArrayThe new list of control points to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Path2D:UpdateControlPoint

Updates the control point at the given index. Throws a warning if the index is out of range.

Parameters

NameTypeDefaultDescription
indexintThe control point index to update.
pointPath2DControlPointThe new Path2DControlPoint value to store at the index.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Events

NameType / ReturnsDescription
Path2D.ControlPointChangedFires any time control points change.

Inherited from Instance

NameType / ReturnsDescription
Instance.AncestryChangedFires when the Instance.Parent property of this object or one of its ancestors is changed.
Instance.AttributeChangedFires whenever an attribute is changed on the Instance.
Instance.ChildAddedFires after an object is parented to this Instance.
Instance.childAdded
Instance.ChildRemovedFires after a child is removed from this Instance.
Instance.DescendantAddedFires after a descendant is added to the Instance.
Instance.DescendantRemovingFires immediately before a descendant of the Instance is removed.
Instance.DestroyingFires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy().
Instance.StyledPropertiesChangedFires whenever any style property is changed on the instance, including when a property is set to nil.

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.

Path2D.ControlPointChanged

Fires whenever the path's control-point data is mutated. This includes calls to Path2D:SetControlPoints(), Path2D:InsertControlPoint(), Path2D:UpdateControlPoint(), and Path2D:RemoveControlPoint(). Does not fire for changes to visual properties such as Path2D.Color3 or Path2D.Thickness.

FieldValue
securityNone
capabilities["UI"]