Skip to content

Drawing class

The Drawing class represents a renderable 2D object that appears on the user's screen. Every specific drawing type (e.g. Circle, Text, Line) inherits from this base and extends it with shape-specific properties.

Drawing objects are not instances - they are client-only graphical primitives that do not interact with the 3D world and must be managed manually.


Constructor

Creates a new render object of the specified type. These objects render directly onto the game window and do not exist in the DataModel.

Inheritance

The returned object inherits from the base Drawing class, and will have specific properties based on its type.

function Drawing.new(type: string): Drawing

Parameters

Parameter Description
type The type of drawing to create. Must be one of: Line, Text, Image, Circle, Square, Quad, or Triangle.

Shared properties

All drawing object types inherit the following fields:

Property Type Description
Visible boolean Whether the object is rendered. Defaults to false.
ZIndex number Render order; higher values appear on top.
Transparency number Opacity (1 = fully opaque, 0 = invisible).
Color Color3 The color of the drawing.
__OBJECT_EXISTS boolean Whether the drawing object exists.

Methods

Method Signature Description
Destroy() Permanently removes the drawing from view.

Shape-specific types

Each subtype of Drawing exposes unique fields that define their visual representation. Below are the supported types:

Line

Property Type Description
From Vector2 Start position of the line.
To Vector2 End position of the line.
Thickness number Width of the line.

Text

Property Type Description
Text string The text content to render.
TextBounds Vector2 🔒 Computed text size (read-only).
Font Drawing.Font Font to use.
Size number Size of the text.
Position Vector2 Top-left corner of the text.
Center boolean Horizontally center the text.
Outline boolean Whether to draw an outline.
OutlineColor Color3 Outline color.

Image

Property Type Description
Data string Raw image byte string (e.g. from readfile).
Size Vector2 Size of the rendered image.
Position Vector2 Top-left corner of the image.
Rounding number Amount of corner rounding (optional aesthetic).

Circle

Property Type Description
NumSides number Number of sides used to approximate the circle.
Radius number Radius of the circle.
Position Vector2 Center point of the circle.
Thickness number Outline thickness (if not filled).
Filled boolean Whether the circle is filled.

Square

Property Type Description
Size Vector2 Size of the rectangle.
Position Vector2 Top-left corner.
Thickness number Outline thickness (if not filled).
Filled boolean Whether the square is filled.

Quad

Property Type Description
PointA Vector2 First point.
PointB Vector2 Second point.
PointC Vector2 Third point.
PointD Vector2 Fourth point.
Thickness number Outline thickness (if not filled).
Filled boolean Whether the quad is filled.

Triangle

Property Type Description
PointA Vector2 First point.
PointB Vector2 Second point.
PointC Vector2 Third point.
Thickness number Outline thickness (if not filled).
Filled boolean Whether the triangle is filled.

Examples

Using the Destroy method.

Creating a circle and destroying the drawing object
local Camera = game.Workspace.CurrentCamera
local Viewport = Camera.ViewportSize
local Position = Vector2.new(Viewport.X / 2, Viewport.Y / 2)

local circle = Drawing.new("Circle")
circle.Radius = 50
circle.Color = Color3.fromRGB(255, 0, 0)
circle.Filled = true
circle.NumSides = 150
circle.Position = Position
circle.Transparency = 1
circle.Visible = true

print(circle.__OBJECT_EXISTS) -- Output: true
circle:Destroy()
print(circle.__OBJECT_EXISTS) -- Output: false

Drawing an Image

Rendering a centered image
local Camera = game.Workspace.CurrentCamera
local Viewport = Camera.ViewportSize
local Position = Vector2.new(Viewport.X / 2, Viewport.Y / 2)
local image = Drawing.new("Image")
image.Data = readfile("your_image.png")
image.Size = Vector2.new(455, 155)
image.Visible = true
image.Position = Position

task.wait(2)
image:Destroy()

Using the __OBJECT_EXISTS property.

Rendering a centered image
local Camera = game.Workspace.CurrentCamera
local Viewport = Camera.ViewportSize
local Position = Vector2.new(Viewport.X / 2, Viewport.Y / 2)

local circle = Drawing.new("Circle")
circle.Radius = 50
circle.Color = Color3.fromRGB(255, 0, 0)
circle.Filled = true
circle.NumSides = 150
circle.Position = Position
circle.Transparency = 1
circle.Visible = true

print(circle.__OBJECT_EXISTS) -- Output: true
circle:Destroy()
print(circle.__OBJECT_EXISTS) -- Output: false