Skip to main content

Draw

Debug drawing library useful for debugging 3D abstractions. One of the more useful utility libraries.

These functions are incredibly easy to invoke for quick debugging. This can make debugging any sort of 3D geometry really easy.

-- A sample of a few API uses
Draw.point(Vector3.new(0, 0, 0))
Draw.terrainCell(Vector3.new(0, 0, 0))
Draw.cframe(CFrame.new(0, 10, 0))
Draw.text(Vector3.new(0, -10, 0), "Testing!")
tip

This library should not be used to render things in production for normal players, as it is optimized for debug experience over performance.

Functions

setColor

Draw.setColor(
colorColor3--

The color to set

) → ()

Sets the Draw's drawing color.

resetColor

Draw.resetColor() → ()

Resets the drawing color.

setRandomColor

Draw.setRandomColor() → ()

Sets the Draw library to use a random color.

line

Draw.line(
startVector3,
finishVector3,
colorColor3,--

Optional

parentInstance?,--

Optional

diameternumber--

Optional

) → Instance

Draws a line between two points

direction

Draw.direction(
originVector3,
directionVector3,
colorColor3,--

Optional

parentInstance?,--

Optional

meshDiameternumber,--

Optional

diameternumber--

Optional

) → Instance

Draws a line between directions

spherecast

Draw.spherecast(
originVector3,
radiusnumber,
directionVector3,
colorColor3,
parentParent
) → ()

Draws a spherecast

tip

Unlike WorldRoot:GetPartsInPart(), spherecast does not detect BaseParts that initially intersect the shape. So this draw doesn't render that initial sphere.

blockcast

Draw.blockcast(
cframeCFrame,
sizeVector3,
directionVector3,
colorColor3,
parentParent
) → ()

Draws a block cast

raycast

Draw.raycast(
originVector3,
directionVector3,
colorColor3,--

Optional

parentInstance?,--

Optional

meshDiameternumber,--

Optional

diameternumber--

Optional

) → Instance

Draws a raycast for debugging

Draw.raycast(origin, direction)

ray

Draw.ray(
rayRay,
colorColor3?,--

Optional color to draw in

parentInstance?,--

Optional parent

diameternumber?--

Optional diameter

) → BasePart

Draws a ray for debugging.

local ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0))
Draw.ray(ray)

updateRay

Draw.updateRay(
rayPartInstance,--

Ray part

rayRay,--

New ray

colorColor3,--

New color

diameternumber--

Number

) → ()

Updates the rendered ray to the new color and position. Used for certain scenarios when updating a ray on renderstepped would impact performance, even in debug mode.

local ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0))
local drawn = Draw.ray(ray)

RunService.RenderStepped:Connect(function()
	local newRay = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10*math.sin(os.clock()), 0))
	Draw.updateRay(drawn, newRay Color3.new(1, 0.5, 0.5))
end)

text

Draw.text(
adorneeInstance | Vector3,--

Adornee to rener on

textstring,--

Text to render

colorColor3?--

Optional color to render

) → Instance

Render text in 3D for debugging. The text container will be sized to fit the text.

Draw.text(Vector3.new(0, 10, 0), "Point")

sphere

Draw.sphere(
positionVector3,--

Position of the sphere

radiusnumber,--

Radius of the sphere

colorColor3?,--

Optional color

parentInstance?--

Optional parent

) → BasePart

Renders a sphere at the given point in 3D space.

Draw.sphere(Vector3.new(0, 10, 0), 10)

Great for debugging explosions and stuff.

point

Draw.point(
positionVector3 | CFrame,--

Point to Draw

colorColor3?,--

Optional color

parentInstance?,--

Optional parent

diameternumber?--

Optional diameter

) → BasePart

Draws a point for debugging in 3D space.

Draw.point(Vector3.new(0, 25, 0), Color3.new(0.5, 1, 0.5))

labelledPoint

Draw.labelledPoint(
positionVector3 | CFrame,--

Position to render

labelstring,--

Label to render on the point

colorColor3?,--

Optional color

parentInstance?--

Optional parent

) → BasePart

Renders a point with a label in 3D space.

Draw.labelledPoint(Vector3.new(0, 10, 0), "AI target")

cframe

Draw.cframe(cframeCFrame) → Model

Renders a CFrame in 3D space. Includes each axis.

Draw.cframe(CFrame.Angles(0, math.pi/8, 0))

part

Draw.part(
templateBasePart,
cframeCFrame,
colorColor3?,
transparencynumber
) → BasePart

Draws a part in 3D space

Draw.part(part, Color3.new(1, 1, 1))

box

Draw.box(
cframeCFrame | Vector3,--

CFrame of the box

sizeVector3,--

Size of the box

colorColor3--

Optional Color3

) → BasePart

Renders a box in 3D space. Great for debugging bounding boxes.

Draw.box(Vector3.new(0, 5, 0), Vector3.new(10, 10, 10))

region3

Draw.region3(
region3Region3,--

Region3 to render

colorColor3?--

Optional color3

) → BasePart

Renders a region3 in 3D space.

Draw.region3(Region3.new(Vector3.new(0, 0, 0), Vector3.new(10, 10, 10)))

terrainCell

Draw.terrainCell(
positionVector3,--

World space position

colorColor3?--

Optional color to render

) → BasePart

Renders a terrain cell in 3D space. Snaps the position to the nearest position.

Draw.terrainCell(Vector3.new(0, 0, 0))

vector

Draw.vector(
positionVector3,--

Position of the vector

directionVector3,--

Direction of the vector. Determines length.

colorColor3?,--

Optional color

parentInstance?,--

Optional instance

meshDiameternumber?--

Optional diameter

) → BasePart

Draws a vector in 3D space.

Draw.vector(Vector3.new(0, 0, 0), Vector3.new(0, 1, 0))

ring

Draw.ring(
ringPosVector3,--

Position of the center of the ring

ringNormVector3,--

Direction of the ring.

ringRadiusnumber?,--

Optional radius for the ring

colorColor3?,--

Optional color

parentInstance?--

Optional instance

) → BasePart

Draws a ring in 3D space.

Draw.ring(Vector3.new(0, 0, 0), Vector3.new(0, 1, 0), 10)

getDefaultParent

Draw.getDefaultParent() → Instance

Retrieves the default parent for the current execution context.

Show raw api
{
    "functions": [
        {
            "name": "setColor",
            "desc": "Sets the Draw's drawing color.",
            "params": [
                {
                    "name": "color",
                    "desc": "The color to set",
                    "lua_type": "Color3"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 40,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "resetColor",
            "desc": "Resets the drawing color.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 47,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "setRandomColor",
            "desc": "Sets the Draw library to use a random color.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 54,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "line",
            "desc": "Draws a line between two points",
            "params": [
                {
                    "name": "start",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "finish",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional",
                    "lua_type": "Color3"
                },
                {
                    "name": "parent",
                    "desc": "Optional",
                    "lua_type": "Instance?"
                },
                {
                    "name": "diameter",
                    "desc": "Optional",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 68,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "direction",
            "desc": "Draws a line between directions",
            "params": [
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "direction",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional",
                    "lua_type": "Color3"
                },
                {
                    "name": "parent",
                    "desc": "Optional",
                    "lua_type": "Instance?"
                },
                {
                    "name": "meshDiameter",
                    "desc": "Optional",
                    "lua_type": "number"
                },
                {
                    "name": "diameter",
                    "desc": "Optional",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 87,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "spherecast",
            "desc": "Draws a spherecast\n\n:::tip\nUnlike WorldRoot:GetPartsInPart(), spherecast does not detect BaseParts\nthat initially intersect the shape. So this draw doesn't render that initial sphere.\n:::",
            "params": [
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "direction",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Parent"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 109,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "blockcast",
            "desc": "Draws a block cast",
            "params": [
                {
                    "name": "cframe",
                    "desc": "",
                    "lua_type": "CFrame"
                },
                {
                    "name": "size",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "direction",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Parent"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 137,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "raycast",
            "desc": "Draws a raycast for debugging\n\n```lua\nDraw.raycast(origin, direction)\n```",
            "params": [
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "direction",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional",
                    "lua_type": "Color3"
                },
                {
                    "name": "parent",
                    "desc": "Optional",
                    "lua_type": "Instance?"
                },
                {
                    "name": "meshDiameter",
                    "desc": "Optional",
                    "lua_type": "number"
                },
                {
                    "name": "diameter",
                    "desc": "Optional",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 266,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "ray",
            "desc": "Draws a ray for debugging.\n\n```lua\nlocal ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0))\nDraw.ray(ray)\n```",
            "params": [
                {
                    "name": "ray",
                    "desc": "",
                    "lua_type": "Ray"
                },
                {
                    "name": "color",
                    "desc": "Optional color to draw in",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional parent",
                    "lua_type": "Instance?"
                },
                {
                    "name": "diameter",
                    "desc": "Optional diameter",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 284,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "updateRay",
            "desc": "Updates the rendered ray to the new color and position.\nUsed for certain scenarios when updating a ray on\nrenderstepped would impact performance, even in debug mode.\n\n```lua\nlocal ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0))\nlocal drawn = Draw.ray(ray)\n\nRunService.RenderStepped:Connect(function()\n\tlocal newRay = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10*math.sin(os.clock()), 0))\n\tDraw.updateRay(drawn, newRay Color3.new(1, 0.5, 0.5))\nend)\n```",
            "params": [
                {
                    "name": "rayPart",
                    "desc": "Ray part",
                    "lua_type": "Instance"
                },
                {
                    "name": "ray",
                    "desc": "New ray",
                    "lua_type": "Ray"
                },
                {
                    "name": "color",
                    "desc": "New color",
                    "lua_type": "Color3"
                },
                {
                    "name": "diameter",
                    "desc": "Number",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 356,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "text",
            "desc": "Render text in 3D for debugging. The text container will\nbe sized to fit the text.\n\n```lua\nDraw.text(Vector3.new(0, 10, 0), \"Point\")\n```",
            "params": [
                {
                    "name": "adornee",
                    "desc": "Adornee to rener on",
                    "lua_type": "Instance | Vector3"
                },
                {
                    "name": "text",
                    "desc": "Text to render",
                    "lua_type": "string"
                },
                {
                    "name": "color",
                    "desc": "Optional color to render",
                    "lua_type": "Color3?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 396,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "sphere",
            "desc": "Renders a sphere at the given point in 3D space.\n\n```lua\nDraw.sphere(Vector3.new(0, 10, 0), 10)\n```\n\nGreat for debugging explosions and stuff.",
            "params": [
                {
                    "name": "position",
                    "desc": "Position of the sphere",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "Radius of the sphere",
                    "lua_type": "number"
                },
                {
                    "name": "color",
                    "desc": "Optional color",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional parent",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 504,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "point",
            "desc": "Draws a point for debugging in 3D space.\n\n```lua\nDraw.point(Vector3.new(0, 25, 0), Color3.new(0.5, 1, 0.5))\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "Point to Draw",
                    "lua_type": "Vector3 | CFrame"
                },
                {
                    "name": "color",
                    "desc": "Optional color",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional parent",
                    "lua_type": "Instance?"
                },
                {
                    "name": "diameter",
                    "desc": "Optional diameter",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 521,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "labelledPoint",
            "desc": "Renders a point with a label in 3D space.\n\n```lua\nDraw.labelledPoint(Vector3.new(0, 10, 0), \"AI target\")\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "Position to render",
                    "lua_type": "Vector3 | CFrame"
                },
                {
                    "name": "label",
                    "desc": "Label to render on the point",
                    "lua_type": "string"
                },
                {
                    "name": "color",
                    "desc": "Optional color",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional parent",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 573,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "cframe",
            "desc": "Renders a CFrame in 3D space. Includes each axis.\n\n```lua\nDraw.cframe(CFrame.Angles(0, math.pi/8, 0))\n```",
            "params": [
                {
                    "name": "cframe",
                    "desc": "",
                    "lua_type": "CFrame"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Model"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 594,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "part",
            "desc": "Draws a part in 3D space\n\n```lua\nDraw.part(part, Color3.new(1, 1, 1))\n```",
            "params": [
                {
                    "name": "template",
                    "desc": "",
                    "lua_type": "BasePart"
                },
                {
                    "name": "cframe",
                    "desc": "",
                    "lua_type": "CFrame"
                },
                {
                    "name": "color",
                    "desc": "",
                    "lua_type": "Color3?"
                },
                {
                    "name": "transparency",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 639,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "box",
            "desc": "Renders a box in 3D space. Great for debugging bounding boxes.\n\n```lua\nDraw.box(Vector3.new(0, 5, 0), Vector3.new(10, 10, 10))\n```",
            "params": [
                {
                    "name": "cframe",
                    "desc": "CFrame of the box",
                    "lua_type": "CFrame | Vector3"
                },
                {
                    "name": "size",
                    "desc": "Size of the box",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional Color3",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 698,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "region3",
            "desc": "Renders a region3 in 3D space.\n\n```lua\nDraw.region3(Region3.new(Vector3.new(0, 0, 0), Vector3.new(10, 10, 10)))\n```",
            "params": [
                {
                    "name": "region3",
                    "desc": "Region3 to render",
                    "lua_type": "Region3"
                },
                {
                    "name": "color",
                    "desc": "Optional color3",
                    "lua_type": "Color3?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 749,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "terrainCell",
            "desc": "Renders a terrain cell in 3D space. Snaps the position\nto the nearest position.\n\n```lua\nDraw.terrainCell(Vector3.new(0, 0, 0))\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "World space position",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional color to render",
                    "lua_type": "Color3?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 767,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "vector",
            "desc": "Draws a vector in 3D space.\n\n```lua\nDraw.vector(Vector3.new(0, 0, 0), Vector3.new(0, 1, 0))\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "Position of the vector",
                    "lua_type": "Vector3"
                },
                {
                    "name": "direction",
                    "desc": "Direction of the vector. Determines length.",
                    "lua_type": "Vector3"
                },
                {
                    "name": "color",
                    "desc": "Optional color",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional instance",
                    "lua_type": "Instance?"
                },
                {
                    "name": "meshDiameter",
                    "desc": "Optional diameter",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 857,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "ring",
            "desc": "Draws a ring in 3D space.\n\n```lua\nDraw.ring(Vector3.new(0, 0, 0), Vector3.new(0, 1, 0), 10)\n```",
            "params": [
                {
                    "name": "ringPos",
                    "desc": "Position of the center of the ring",
                    "lua_type": "Vector3"
                },
                {
                    "name": "ringNorm",
                    "desc": "Direction of the ring.",
                    "lua_type": "Vector3"
                },
                {
                    "name": "ringRadius",
                    "desc": "Optional radius for the ring",
                    "lua_type": "number?"
                },
                {
                    "name": "color",
                    "desc": "Optional color",
                    "lua_type": "Color3?"
                },
                {
                    "name": "parent",
                    "desc": "Optional instance",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 879,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        },
        {
            "name": "getDefaultParent",
            "desc": "Retrieves the default parent for the current execution context.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 976,
                "path": "src/draw/src/Shared/Draw.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Draw",
    "desc": "Debug drawing library useful for debugging 3D abstractions. One of\nthe more useful utility libraries.\n\nThese functions are incredibly easy to invoke for quick debugging.\nThis can make debugging any sort of 3D geometry really easy.\n\n```lua\n-- A sample of a few API uses\nDraw.point(Vector3.new(0, 0, 0))\nDraw.terrainCell(Vector3.new(0, 0, 0))\nDraw.cframe(CFrame.new(0, 10, 0))\nDraw.text(Vector3.new(0, -10, 0), \"Testing!\")\n```\n\n:::tip\nThis library should not be used to render things in production for\nnormal players, as it is optimized for debug experience over performance.\n:::",
    "source": {
        "line": 23,
        "path": "src/draw/src/Shared/Draw.lua"
    }
}