Class · inherits GuiBase
Path2D
Represents a 2D cubic spline path that renders a stroked curve under any
GuiObject.
About Path2D
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 5
Closed
: booleanConnects the first and last control points when enabled.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 tofalse.Color3
: Color3Determines the color of thePath2D.Determines the stroke color used to render the
Path2D. Defaults to[0, 0, 0](black). A childUIGradientcan override the solid color with a gradient fill.ZIndex
: intDetermines the order in which aPath2Dpath renders relative to other GUIs.Determines the order in which a
Path2Dpath renders relative to other GUIs. Works the same asGuiObject.ZIndexbut does not interact with layout order in any way.
Methods 13
GetControlPoint
(index: int) → Path2DControlPointReturns thePath2DControlPointfor a given index.Returns the
Path2DControlPointfor a given index. If the index is out of bounds, this method will throw an error.GetControlPoints
() → ArrayReturns all thePath2DControlPointsfor thePath2D.Returns a table of all the
Path2DControlPointsfor thePath2D.GetMaxControlPoints
() → intReturns the maximum allowed number of control points.Returns
100, the hard upper limit on the number of control points aPath2Dcan contain. Attempting to add points beyond this limit viaPath2D.InsertControlPointorPath2D.SetControlPointsthrows an error.GetPositionOnCurve
(t: float) → UDim2Returns the position at a given value in parameter space.Returns the 2D
UDim2position at a giventvalue between0and1(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; seeGetPositionOnCurveArcLength()for even spacing results.Throws an error if the
Path2Dhas less than two control points.GetPositionOnCurveArcLength
(t: float) → UDim2Returns the position at a given value in arc length space.Returns the 2D
UDim2position at a giventvalue between0and1(inclusive), representing the arc length space result of querying the spline. The values will be evenly spaced along the spline; seeGetPositionOnCurve()for parameter spacing results.Throws an error if the
Path2Dhas less than two control points.GetTangentOnCurve
(t: float) → Vector2Returns the tangent at a given value in parameter space.Returns the tangent at a given
tvalue in parameter space wheretis a value between0and1(inclusive). Throws an error if thePath2Dhas less than two control points.GetTangentOnCurveArcLength
(t: float) → Vector2Returns the tangent at a given value in arc length space.Returns the tangent at a given
tvalue in arc length space wheretis a value between0and1(inclusive). Throws an error if thePath2Dhas less than two control points.InsertControlPoint
(index: int, point: Path2DControlPoint) → ()Inserts a new control point at a given index.Inserts a new
Path2DControlPointat 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.RemoveControlPoint
(index: int) → ()Removes a control at the given index.Removes a control point at the given index. Throws a warning if the index is out of bounds.
SetControlPoints
(controlPoints: Array) → ()Sets all the control points to the specified array, replacing all existing points with new ones.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
controlPointsarray.UpdateControlPoint
(index: int, point: Path2DControlPoint) → ()Updates a control point at the given index.Updates the control point at the given index. Throws a warning if the index is out of range.
Events 1
ControlPointChanged
Path2D.ControlPointChanged:Connect(function())Fires any time control points change.Fires whenever the path's control-point data is mutated. This includes calls to
Path2D.SetControlPoints,Path2D.InsertControlPoint,Path2D.UpdateControlPoint, andPath2D.RemoveControlPoint. Does not fire for changes to visual properties such asPath2D.Color3orPath2D.Thickness.
Path2D also has every member of GuiBase. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.