Skip to content

Class · inherits GuiBase

Path2D

Official docs ↗

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 to false.

  • Color3: Color3Determines the color of the Path2D.

    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.

  • Thickness: floatDetermines how thick the Path2D path is.

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

  • Visible: booleanDetermines if the Path2D path is rendered or not.

    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: intDetermines the order in which a Path2D path renders relative to other GUIs.

    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() → RectReturns the bounding size for the Path2D.

    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.

  • GetControlPoint(index: int) → Path2DControlPointReturns the Path2DControlPoint for a given index.

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

  • GetControlPoints() → ArrayReturns all the Path2DControlPoints for the Path2D.

    Returns a table of all the Path2DControlPoints for the Path2D.

  • GetLength() → floatReturns the length of the Path2D.

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

  • GetMaxControlPoints() → intReturns the maximum allowed number of control points.

    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.

  • GetPositionOnCurve(t: float) → UDim2Returns the position at a given value in parameter space.

    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.

  • GetPositionOnCurveArcLength(t: float) → UDim2Returns the position at a given value in arc length space.

    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.

  • GetTangentOnCurve(t: float) → Vector2Returns the tangent at a given value in parameter space.

    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.

  • GetTangentOnCurveArcLength(t: float) → Vector2Returns the tangent at a given value in arc length space.

    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.

  • InsertControlPoint(index: int, point: Path2DControlPoint) → ()Inserts a new control point at a given index.

    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.

  • 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 controlPoints array.

  • 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

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.