Skip to content

World Drawing

The World Drawing API allows you to draw on the game world. This is useful for debugging, creating visual aids, or replay analysis.

Usage

The most commonly used functions in the World Drawing API are:

WorldDraw.drawLine()
WorldDraw.drawPoint()
WorldDraw.clear()

Additional functions are available for more advanced use cases:

WorldDraw.drawTriangle() -- draws a one-sided triangle from three points
WorldDraw.clearAll()     -- clears all lines, points, and lights
WorldDraw.clearLights()  -- clears only spawned lights
WorldDraw.spawnPointLight() -- spawns a point light, returns a LuauPointLight

For the full signatures and the LuauPointLight types, see types/world.d.lua.

WorldDraw.drawLine()

WorldDraw.drawLine(startPos: Vec3, endPos: Vec3, r: number, g: number, b: number, thickness: number, lifetime: number)

This draws a line from startPos to endPos with the specified color and thickness. The line will disappear after the specified lifetime in seconds. If a lifetime of 0 is specified, the line will be permanent until WorldDraw.clear() is called.

WorldDraw.drawPoint()

WorldDraw.drawPoint(position: Vec3, r: number, g: number, b: number, pointSize: number, lifetime: number)

This draws a point at position with the specified color and size. The point will disappear after the specified lifetime in seconds. If a lifetime of 0 is specified, the point will be permanent until WorldDraw.clear() is called. The point size is in screen pixels, and will scale when you get closer or further from the point in the game world.

WorldDraw.clear()

WorldDraw.clear()

This removes all lines and points drawn on the world, even if they were set to be permanent.