task
SDK 0.1.0-preview.1 · ExperimentalDownload & release notes ↗
Schedules callbacks in LUI. Use a task for I/O methods that yield.
Example
Section titled “Example”Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
local Window = Instance.new("Window", { Title = "LUI example", Size = UDim2.fromOffset(560, 280),})local Status = Instance.new("TextLabel", { Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170), Size = UDim2.new(1, -32, 0, 72),})task.defer(function() Status.Text = "Deferred callback ran" end)task.delay(1, function() Status.Text = "Delayed callback ran" end)Window.Visible = trueExpected result: The status changes after scheduled callbacks run. These tasks run through LUI’s scheduler, not unrestricted native threads.
Full type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
declare task: { read defer: (Callback: () -> ()) -> (), read spawn: (Callback: () -> ()) -> (), read delay: (Seconds: number, Callback: () -> ()) -> (),}