Win Lua VM API Documentation

Global 'game' Table

The global `game` table provides access to core game functionalities, objects, and events.

Properties & Objects

game:GetDataModel() -> Instance

Retrieves the main DataModel instance of the game.

game:GetWorkspace() -> Instance

Retrieves the Workspace instance.

game:GetCamera() -> Instance

Retrieves the current Camera instance.

game:GetLocalPlayer() -> Player

Retrieves the local Player object.

game:GetPlayers() -> Instance

Retrieves the Players service instance.

game:GetVisualEngine() -> VisualEngine

Retrieves the VisualEngine object.

game:GetPlayerCache() -> table<Player>

Retrieves a table (array) of cached Player objects.

Global 'drawing' Table

The global `drawing` table provides functions for 2D rendering on the screen. Coordinates are typically screen-based (top-left is 0,0). Drawings are cleared each frame after rendering.

drawing:get_screen_size() -> vector2

Returns the current screen dimensions.

Return Type Description
screenSize vector2 A table {x, y} representing screen width and height.
drawing:draw_line(vector2 startPos, vector2 endPos, Color color, number thickness?)

Draws a line on the screen.

Parameter Type Description
startPos vector2 The starting {x, y} coordinates of the line.
endPos vector2 The ending {x, y} coordinates of the line.
color Color The color of the line.
thickness? number Optional. The thickness of the line. Defaults to 1.0.
drawing:draw_circle(vector2 centerPos, number radius, Color color, boolean filled, number thickness?, integer segments?)

Draws a circle on the screen.

Parameter Type Description
centerPos vector2 The center {x, y} coordinates of the circle.
radius number The radius of the circle.
color Color The color of the circle.
filled boolean If true, the circle is filled; otherwise, it's an outline.
thickness? number Optional. The thickness of the outline if not filled. Defaults to 1.0.
segments? integer Optional. The number of segments to use for drawing the circle. 0 for auto. Defaults to 0.
drawing:draw_rectangle(vector2 topLeftPos, vector2 size, Color color, boolean filled, number thickness?, number rounding?)

Draws a rectangle on the screen.

Parameter Type Description
topLeftPos vector2 The top-left {x, y} coordinates of the rectangle.
size vector2 The {width, height} of the rectangle.
color Color The color of the rectangle.
filled boolean If true, the rectangle is filled; otherwise, it's an outline.
thickness? number Optional. The thickness of the outline if not filled. Defaults to 1.0.
rounding? number Optional. The corner rounding radius. Defaults to 0.0.
drawing:draw_text(vector2 position, string text, Color color, number fontSize?)

Draws text on the screen. Note: `fontSize` effect depends on underlying font rendering capabilities.

Parameter Type Description
position vector2 The top-left {x, y} coordinates for the text.
text string The string to draw.
color Color The color of the text.
fontSize? number Optional. Desired font size. Effect may be limited with default ImGui font handling. Defaults to 0 (uses current/default font size).

Type: Instance

Represents a generic Roblox object in the game hierarchy. Corresponds to `win_v4::rbx::instance`.

Instance:GetName() -> string

Returns the name of the instance.

Instance:GetClassName() -> string

Returns the class name of the instance.

Instance:GetChildren() -> table<Instance>

Returns a table (array) of the instance's direct children.

Instance:GetDescendants() -> table<Instance>

Returns a table (array) of all descendants of the instance.

Instance:FindFirstChild(string name) -> Instance | nil

Finds the first child with the given name.

Instance:FindFirstChildContaining(string namePart) -> Instance | nil

Finds the first child whose name contains the given string.

Instance:FindFirstChildOfClass(string className) -> Instance | nil

Finds the first child that is of the given class name.

Instance:GetParent() -> Instance | nil

Returns the parent of the instance.

Instance:GetPrimitive() -> Primitive | nil

Returns the Primitive object associated with this instance, if applicable (e.g., for Parts).

Instance:GetService(string serviceName) -> Instance | nil

Gets a service by name (typically called on DataModel or similar top-level instances).

Instance:GetCameraPosition() -> vector3

Gets the camera position (likely if this instance is a Camera or related to it).

Instance:SetCameraPosition(vector3 position)

Sets the world space position of the camera.

Instance:SetCameraRotation(matrix3 rotation)

Sets the camera rotation matrix.

Instance:SetLookVector(vector3 lookVector)

Sets the camera's look vector.

Instance:SetWalkspeed(number speed)

Sets the walkspeed (likely for a Humanoid instance).

Instance:GetTeam() -> Instance | nil

Gets the team instance (likely for a Player or objects associated with teams).

Instance:GetHealth() -> number

Gets the health (likely for a Humanoid or Player model).

Instance:GetMaxHealth() -> number

Gets the maximum health (likely for a Humanoid or Player model).

Instance:GetUIPosition() -> udim2

Gets the UI position of a GUI element.

Instance:SetUIPosition(udim2 position)

Sets the UI position of a GUI element.

Instance:GetUISize() -> vector2

Gets the UI size of a GUI element.

Instance:GetAbsolutePosition() -> vector2

Gets the absolute screen position of a GUI element.

Instance:GetLocalPlayerInstance() -> Instance | nil

Gets the local player's character model instance (or player instance, context dependent).

Instance:GetModelInstance() -> Instance | nil

Gets the model instance associated with this instance (e.g., character model from Player instance).

Type: Primitive

Represents a physical part in the game world (e.g., Part, MeshPart). Corresponds to `win_v4::rbx::primitive`.

Primitive:GetPosition() -> vector3

Returns the world space position of the primitive.

Primitive:GetRotation() -> matrix3

Returns the rotation matrix of the primitive.

Primitive:GetSize() -> vector3

Returns the size of the primitive.

Primitive:SetPosition(vector3 position)

Sets the world space position of the primitive.

Primitive:GlideTo(vector3 target, number speed, integer steps)

Smoothly moves the primitive to a target position.

Primitive:GetSizePosRot() -> sizeposrot

Returns a table containing the size, position, and rotation of the primitive.

Primitive:SetVelocity(vector3 velocity)

Sets the linear velocity of the primitive.

Type: VisualEngine

Represents the game's rendering engine. Corresponds to `win_v4::rbx::visualengine`.

VisualEngine:GetDataModel() -> Instance

Retrieves the main DataModel instance from the VisualEngine's perspective.

VisualEngine:WorldToScreen(vector3 worldPosition) -> vector2

Converts a 3D world position to a 2D screen coordinate.

Return Type Description
screenPos vector2 The (x, y) screen coordinates.

Type: Player

Represents a player in the game. Corresponds to `win_v4::rbx::player`.

Player:GetName() -> string

Returns the name of the player.

Player:IsR6() -> boolean

Returns true if the player's character is R6, false otherwise.

Player:IsR15() -> boolean

Returns true if the player's character is R15, false otherwise.

Player:IsVisible() -> boolean

Returns true if the player's character is currently visible.

Player:IsLocalPlayer() -> boolean

Returns true if this is the local player.

Player:GetHealth() -> number

Returns the current health of the player's character.

Player:GetMaxHealth() -> number

Returns the maximum health of the player's character.

Player:GetCharacterChildren() -> table<Instance>

Returns a table (array) of the player's character model's children.

Player:GetHead() -> Instance | nil

Returns the Head instance of the player's character.

Player:GetHumanoidRootPart() -> Instance | nil

Returns the HumanoidRootPart instance of the player's character.

Player:GetHumanoid() -> Instance | nil

Returns the Humanoid instance of the player's character.

Player:GetTeam() -> Instance | nil

Returns the Team instance the player belongs to.

Player:GetPlayerInstance() -> Instance | nil

Returns the Player instance from the Players service that corresponds to this player object.

Player:GetModelInstance() -> Instance | nil

Returns the character model Instance of the player.

Type: Event Objects

Event objects allow you to connect functions to specific occurrences within the VM or game. Example: game.OnRender.

Event:Connect(function callback) -> table

Connects a Lua function to be called when the event fires.

Parameter Type Description
callback function The function to execute when the event occurs. It will be called with no arguments.
Return Type Description
connection table A connection object. Currently, this object contains 'Function' (the callback) and 'Ref' (internal registry reference). A Disconnect method may be added in the future.
local connection = game.OnRender(function()
    print("Render frame!")
end)

Custom Data Types

These are represented as Lua tables with specific fields.

vector2

A 2D vector, used for screen coordinates and UI dimensions.

  • x: number - The X component.
  • y: number - The Y component.
local point = { x = 100, y = 150 }

vector3

A 3D vector.

  • x: number - The X component.
  • y: number - The Y component.
  • z: number - The Z component.
local pos = { x = 10, y = 20, z = 30 }

matrix3

A 3x3 matrix, represented as a Lua table with 9 numeric elements (1-indexed).

  • [1] to [9]: number - The matrix elements in row-major order.
local rot = { 1, 0, 0, 0, 1, 0, 0, 0, 1 } -- Identity matrix

udim2

A 2D data type used for UI sizing and positioning, combining scale and offset.

  • XScale: number - X-axis scale component.
  • XOffset: number - X-axis offset component (in pixels).
  • YScale: number - Y-axis scale component.
  • YOffset: number - Y-axis offset component (in pixels).
local uiPos = { XScale = 0.5, XOffset = 10, YScale = 0.1, YOffset = 5 }

Color

Represents an RGBA color. Component values should be between 0 and 255.

  • r: integer - Red component (0-255).
  • g: integer - Green component (0-255).
  • b: integer - Blue component (0-255).
  • a: integer - Alpha component (0-255). Defaults to 255 if not provided.
local redColor = { r = 255, g = 0, b = 0 }
local semiTransparentGreen = { r = 0, g = 255, b = 0, a = 128 }

sizeposrot

A table containing size, position, and rotation information for a Primitive.

  • size: vector3 - The size of the object.
  • position: vector3 - The position of the object.
  • rotation: matrix3 - The rotation matrix of the object.