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(
color: Color3--

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.

ray​

Draw.ray(
ray: Ray,
color: Color3?,--

Optional color to draw in

parent: Instance?,--

Optional parent

meshDiameter: number?,--

Optional mesh diameter

diameter: number?--

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(
part: Raypart,
ray: Ray,
color: Color3
) → ()

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(
adornee: Instance | Vector3,--

Adornee to rener on

text: string,--

Text to render

color: Color3?--

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(
position: Vector3,--

Position of the sphere

radius: number,--

Radius of the sphere

color: Color3?,--

Optional color

parent: Instance?--

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(
position: Vector3 | CFrame,--

Point to Draw

color: Color3?,--

Optional color

parent: Instance?,--

Optional parent

diameter: number?--

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(
position: Vector3 | CFrame,--

Position to render

label: string,--

Label to render on the point

color: Color3?,--

Optional color

parent: Instance?--

Optional parent

) → BasePart

Renders a point with a label in 3D space.

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

cframe​

Draw.cframe(cframe: CFrame) → Model

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

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

part​

Draw.part(
template: BasePart,
cframe: CFrame,
color: Color3?,
transparency: number
) → BasePart

Draws a part in 3D space

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

box​

Draw.box(
cframe: CFrame | Vector3,--

CFrame of the box

size: Vector3,--

Size of the box

color: Color3--

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(
region3: Region3,--

Region3 to render

color: Color3?--

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(
position: Vector3,--

World space position

color: Color3?--

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(
position: Vector3,--

Position of the vector

direction: Vector3,--

Direction of the vector. Determines length.

color: Color3?,--

Optional color

parent: Instance?,--

Optional instance

meshDiameter: number?--

Optional diameter

) → BasePart

Draws a vector in 3D space.

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

ring​

Draw.ring(
ringPos: Vector3,--

Position of the center of the ring

ringNorm: Vector3,--

Direction of the ring.

ringRadius: number?,--

Optional radius for the ring

color: Color3?,--

Optional color

parent: Instance?--

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": "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": "meshDiameter",
                    "desc": "Optional mesh diameter",
                    "lua_type": "number?"
                },
                {
                    "name": "diameter",
                    "desc": "Optional diameter",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BasePart"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 73,
                "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": "part",
                    "desc": "",
                    "lua_type": "Ray part"
                },
                {
                    "name": "ray",
                    "desc": "",
                    "lua_type": "Ray"
                },
                {
                    "name": "color",
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 152,
                "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": 188,
                "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": 294,
                "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": 311,
                "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": 366,
                "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": 388,
                "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": 431,
                "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": 488,
                "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": 535,
                "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": 551,
                "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": 636,
                "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": 654,
                "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": 684,
                "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"
    }
}