Skip to content

assets

Play, stop, and query local audio files via a system media player, plus read Roblox Sound instance metadata.

audio.Play(path: string, loop: boolean?, volume: number?, pitch: number?) -> (ok: boolean, pidOrError: number|string)

Plays a local file confined to the fs workspace through the first available system media player (mpv, ffplay, paplay, cvlc, or aplay), replacing any currently playing audio started this way.

local ok, pid = audio.Play("sounds/theme.mp3", true, 0.8, 1.0)
if not ok then print(pid) end

audio.Stop() -> stopped: boolean

Terminates the audio player process started by audio.Play, if one is running.

audio.Stop()

audio.IsPlaying() -> playing: boolean

Returns whether the audio player process started by audio.Play is still alive.

if audio.IsPlaying() then print("still playing") end

audio.Metadata(sound: Instance) -> table|nil

Reads a Roblox Sound instance’s SoundId, Volume, PlaybackSpeed, TimeLength, TimePosition, Looped, Playing, IsPaused, IsLoaded, and RollOffMaxDistance properties into a table, returning nil if the instance or engine handle is unavailable.

local meta = audio.Metadata(sound)
if meta then print(meta.SoundId, meta.Volume) end

Load custom fonts for the draw API and get or set the default font used for text rendering.

font.Load(path: string) -> any

Loads a font file by delegating to draw.LoadFont and returns whatever draw.LoadFont returns, or false if draw.LoadFont is unavailable.

local handle = font.Load("fonts/Roboto-Regular.ttf")

font.SetDefault(path: string) -> boolean

Sets the default font path by writing it to settings under the key font, returns true on success or false if the settings table is unavailable.

local ok = font.SetDefault("fonts/Roboto-Regular.ttf")

font.Get() -> string | nil

Returns the current default font path read from settings, or nil if unavailable.

local current = font.Get()

Load static images and GIFs from the confined workspace and draw or sample them.

image.Load(path: string) -> Image | nil, string?

Decodes an image file from the fs-confined workspace into an Image object, returning nil plus an error string on failure.

local img, err = image.Load("textures/logo.png")
if img then print(img.Width, img.Height) end

image.LoadGif(path: string) -> Gif | nil, string?

Decodes a GIF file from the fs-confined workspace into a Gif object with all frames and per-frame delays, returning nil plus an error string on failure.

local gif, err = image.LoadGif("anim/spinner.gif")
if gif then print(gif.Frames) end

Image.Width: number

The pixel width of a loaded image.

local img = image.Load("a.png")
print(img.Width)

Image.Height: number

Pixel height of a loaded Image.

local img = image.Load("a.png")
print(img.Height)

Image.Size: Vector2

Width and height of the Image packed as a Vector2.

local img = image.Load("a.png")
print(img.Size)

Image.Path: string

Resolved, confined filesystem path the Image was loaded from.

local img = image.Load("a.png")
print(img.Path)

Image:GetPixel(x: number, y: number) -> Color3, number | nil

Reads the color and alpha (0 to 1) of a 0-based pixel coordinate, returning nil if the coordinate is out of bounds.

local img = image.Load("a.png")
local color, alpha = img:GetPixel(0, 0)

Image:Draw(x: number, y: number, w: number?, h: number?, alpha: number?)

Draws the Image to the overlay at the given position, defaulting width, height and alpha to the image’s native size and full opacity; delegates to the global draw.Image function.

local img = image.Load("a.png")
img:Draw(100, 100)

Gif.Width: number

Pixel width of a loaded Gif’s frames.

local gif = image.LoadGif("a.gif")
print(gif.Width)

Gif.Height: number

Pixel height of a loaded Gif’s frames.

local gif = image.LoadGif("a.gif")
print(gif.Height)

Gif.Frames: number

Total number of decoded frames in the Gif.

local gif = image.LoadGif("a.gif")
print(gif.Frames)

Gif:Draw(x: number, y: number, w: number?, h: number?, alpha: number?)

Draws the currently-due animation frame at the given position based on elapsed time since first draw, defaulting size to native and alpha to full opacity.

local gif = image.LoadGif("a.gif")
-- call every frame to animate
gif:Draw(50, 50)