Guides
Drawing each frame
Render with DrawingImmediate and release the paint connection.
Drawing.new creates a retained object: you set its properties and remove it when finished. DrawingImmediate works differently. Its commands exist only for one paint frame, so the code that draws them must run again on the next frame.
Paint each frame
GetPaint provides the paint signal for a layer. Connect a callback, issue drawing commands inside it, and keep the connection so you can stop later:
local paint = DrawingImmediate.GetPaint(10)
local connection = paint:Connect(function()
DrawingImmediate.FilledRectangle(
Vector2.new(20, 20),
Vector2.new(160, 36),
Color3.fromRGB(24, 24, 24),
1
)
DrawingImmediate.Text(
Vector2.new(28, 28),
Drawing.Fonts.UI,
16,
Color3.new(1, 1, 1),
1,
"Example",
false
)
end)
-- When this overlay is no longer needed:
connection:Disconnect()Limits and argument order
- Drawing outside a paint callback raises an error.
- Layers paint in ascending z-index order; the queue holds at most 1,024 primitives per frame.
- Keep expensive calculations outside the callback when possible.
The functions do not all use identical argument order. In particular, Circle takes opacity before sides, while FilledCircle takes sides before opacity. Check each signature before switching between the two.
