Class
Path2D
Represents a 2D cubic spline path that renders a stroked curve under any
GuiObject.
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.
Properties 7#
Closedboolean | Connects the first and last control points when enabled.ReadSafe |
Color3Color3 | Determines the color of the Path2D.ReadSafe |
SelectedControlPointint | Index of the currently selected Path2DControlPoint.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeNotReplicated |
SelectedControlPointDataPath2DControlPoint | Path2DControlPoint data type representing the currently
selected control point.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeNotReplicated |
Thicknessfloat | Determines how thick the Path2D path is.ReadSafe |
Visibleboolean | Determines if the Path2D path is rendered or not.ReadSafe |
ZIndexint | Determines the order in which a Path2D path renders relative to
other GUIs.ReadSafe |
Closed: boolean#
ReadSafe
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.
Color3: Color3#
ReadSafe
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.
SelectedControlPoint: int#
NotReplicatedRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
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.
SelectedControlPointData: Path2DControlPoint#
NotReplicatedRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
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}).
Thickness: float#
ReadSafe
Determines the stroke width of the Path2D in pixels. Defaults to
1 and is clamped to the range [0, 100].
Visible: boolean#
ReadSafe
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.
ZIndex: int#
ReadSafe
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.
Methods 13#
| GetBoundingRect | Returns the bounding size for the Path2D. |
| GetControlPoint | Returns the Path2DControlPoint for a given index. |
| GetControlPoints | Returns all the Path2DControlPoints for the
Path2D. |
| GetLength | Returns the length of the Path2D. |
| GetMaxControlPoints | Returns the maximum allowed number of control points. |
| GetPositionOnCurve | Returns the position at a given value in parameter space. |
| GetPositionOnCurveArcLength | Returns the position at a given value in arc length space. |
| GetTangentOnCurve | Returns the tangent at a given value in parameter space. |
| GetTangentOnCurveArcLength | Returns the tangent at a given value in arc length space. |
| InsertControlPoint | Inserts a new control point at a given index. |
| RemoveControlPoint | Removes a control at the given index. |
| SetControlPoints | Sets all the control points to the specified array, replacing all existing points with new ones. |
| UpdateControlPoint | Updates a control point at the given index. |
GetBoundingRect(): Rect#
GetControlPoint(index: int): Path2DControlPoint#
Returns the Path2DControlPoint for a given index. If the index
is out of bounds, this method will throw an error.
| Name | Type | Default | Description |
|---|---|---|---|
index | int | The 1-based index of the control point to return. |
Returns
Path2DControlPoint— The control point at the given index.
GetControlPoints(): Array#
Returns a table of all the
Path2DControlPoints for the Path2D.
Returns
Array— Table of all thePath2DControlPoints.
GetLength(): float#
Returns the length of the Path2D. This function can be expensive
if called too frequently.
Returns
float— The total length of the path.
GetMaxControlPoints(): int#
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
int— The maximum number of control points aPath2Dsupports.
GetPositionOnCurve(t: float): UDim2#
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.
| Name | Type | Default | Description |
|---|---|---|---|
t | float | The value to query the Path2D at. |
Returns
UDim2— The position in parameter space.
GetPositionOnCurveArcLength(t: float): UDim2#
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.
| Name | Type | Default | Description |
|---|---|---|---|
t | float | The value to query the Path2D at. |
Returns
UDim2— The position in arc length space.
GetTangentOnCurve(t: float): Vector2#
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.
| Name | Type | Default | Description |
|---|---|---|---|
t | float | The value to query the Path2D at. |
Returns
Vector2— The tangent in parameter space.
GetTangentOnCurveArcLength(t: float): Vector2#
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.
| Name | Type | Default | Description |
|---|---|---|---|
t | float | The value to query the Path2D at. |
Returns
Vector2— The tangent in arc length space.
InsertControlPoint(index: int, point: Path2DControlPoint): ()#
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.
| Name | Type | Default | Description |
|---|---|---|---|
index | int | The index to insert at. | |
point | Path2DControlPoint | The control point to insert. |
Returns
()
RemoveControlPoint(index: int): ()#
Removes a control point at the given index. Throws a warning if the index is out of bounds.
| Name | Type | Default | Description |
|---|---|---|---|
index | int | The index to remove at. |
Returns
()
SetControlPoints(controlPoints: Array): ()#
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.
| Name | Type | Default | Description |
|---|---|---|---|
controlPoints | Array | The new list of control points to set. |
Returns
()
UpdateControlPoint(index: int, point: Path2DControlPoint): ()#
Updates the control point at the given index. Throws a warning if the index is out of range.
| Name | Type | Default | Description |
|---|---|---|---|
index | int | The control point index to update. | |
point | Path2DControlPoint | The new Path2DControlPoint value to store at the index. |
Returns
()
Events 1#
| ControlPointChanged | Fires any time control points change. |
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.
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild