System
System-level APIs and environment constraints.
This page is aligned to the June 4, 2026 compatibility baseline: public npm runtime line 2.37.8, with source pins tracked in Runtime Compatibility Baseline.
Listener
Callback that observes changes on an object. Supports two calling conventions:
Usage
-- Simple callback
property:addListener(function()
print("Value changed to", property.value)
end)
-- Bound object callback
property:addListener(self, function(obj)
print("Changed on", obj)
end)
Output
Output<T> appears in upstream docs, but at the current C++ runtime baseline it is not exposed in Luau bindings.
Current guidance
function advance(self: MyScript, seconds: number): boolean
-- Use regular typed fields on self for script state
self.result = math.sin(seconds)
self.label = "Hello"
return true
end
Do not rely on Output<T> in course code until a future runtime baseline confirms exposure.
Track changes in Runtime Compatibility Baseline.
EnumValues
Collection of enum values. Supports length operator and indexed access.
Operators
Length (#)
Returns the number of enum values.
local count = #enumValues
Index ([])
Access individual enum values by index.
local firstOption = enumValues[1]
Example
local enum = vm:getEnum("status")
local values = enum:values()
for i = 1, #values do
print(i, values[i])
end
See Also: PropertyEnum
Promise, async, and await
Promise utilities are available in the runtime and support chaining, cancellation, and coroutine-style async flows.
Promise static methods
Promise.new(executor: (resolve: (any) -> (), reject: (any) -> (), onCancel: ((() -> ())?) -> ()) -> ()): Promise
Promise.resolve(value: any?): Promise
Promise.reject(reason: any?): Promise
Promise.all(promises: {Promise}): Promise
Promise instance methods
promise:andThen(onFulfilled: (any) -> any, onRejected: ((any) -> any)?): Promise
promise:catch(onRejected: (any) -> any): Promise
promise:finally(callback: () -> ()): Promise
promise:cancel()
promise:onCancel(callback: () -> ())
promise:getStatus(): "pending" | "fulfilled" | "rejected" | "cancelled"
async(fn) and await(promise)
await(promise) must be called inside an async(...) function.
local run = async(function()
local ok, result = await(fetchSomething())
if ok then
print("resolved:", result)
else
print("failed:", result)
end
end)
run:andThen(function()
print("done")
end)
await(...) is non-throwing and returns (ok, valueOrError). Handle both branches explicitly.
Sandbox Limitations
Not available in Rive's Luau environment:
| Library | Status |
|---|---|
io | Not available |
os | Partial (os.clock(), os.time(), os.difftime() only) |
debug | Not available |
package | Not available |
loadfile, dofile, loadstring | Not available |
The __gc metamethod is also disabled.
late()
Deferred initialization marker for script fields. Use in factory return tables for fields that will be assigned later (e.g., in init()).
declare function late(): any
Example
return function(): Node<MyScript>
return {
init = init,
advance = advance,
myPath = late(), -- Will be assigned in init()
myPaint = late(),
}
end
Audio
Global API for audio playback. Used with AudioSource assets.
Methods
Audio.time()
Returns the current audio system time in seconds.
Audio.time(): number
Audio.sampleRate()
Returns the audio sample rate.
Audio.sampleRate(): number
Audio.timeFrame()
Returns the current audio system time in frames.
Audio.timeFrame(): number
Audio.play(source)
Plays an audio source immediately. Returns an AudioSound for controlling playback.
Audio.play(source: AudioSource): AudioSound
Audio.playAtTime(source, time)
Schedules playback at a specific audio time.
Audio.playAtTime(source: AudioSource, time: number): AudioSound
Audio.playInTime(source, delay)
Schedules playback after a delay in seconds.
Audio.playInTime(source: AudioSource, delay: number): AudioSound
Audio.playAtFrame(source, frame)
Schedules playback at a specific frame.
Audio.playAtFrame(source: AudioSource, frame: number): AudioSound
Audio.playInFrame(source, frames)
Schedules playback after a delay in frames.
Audio.playInFrame(source: AudioSource, frames: number): AudioSound
Example
function init(self: MyScript, context: Context): boolean
local source = context:audio("click_sound")
if source then
local sound = Audio.play(source)
sound.volume = 0.8
end
return true
end
See Also: AudioSource, AudioSound, Context
Knowledge Check
Next Steps
- Continue to Quick Reference
- Verify surface status in Runtime Compatibility Baseline
- Review key terms in Glossary