Skip to content

globals

Bare Roblox-style globals available to every script: the game root instance, the task scheduler, legacy spawn/wait globals, tick, and the Enum table.

game : Instance (DataModel)

The root DataModel instance. Use it like any other Instance: game:GetService(...), game:FindFirstChild(...), or index its children directly with game.Workspace.

local ws = game:GetService("Workspace")
print(game.Name)

task.spawn(fn: function, ...: any) -> thread

Creates a new coroutine from fn, resumes it immediately with the given args, and returns the underlying thread.

task.spawn(function(a) print("spawned", a) end, 42)

task.defer(fn: function, ...: any) -> thread

Creates a new coroutine from fn and schedules it to resume on the next scheduler pump rather than immediately.

task.defer(function() print("runs next tick") end)

task.delay(seconds: number, fn: function, ...: any) -> thread

Creates a new coroutine from fn and schedules it to resume after at least seconds have elapsed.

task.delay(2, function() print("2s later") end)

task.wait(seconds: number?) -> number

Yields the current coroutine until at least seconds (default 0) have elapsed, then resumes it with the actual elapsed time.

local elapsed = task.wait(1)
print("waited", elapsed)

task.cancel(thread: thread) -> ()

Removes a pending scheduled task (from spawn/defer/delay/wait) matching the given thread so it never resumes.

local t = task.delay(5, print, "never")
task.cancel(t)

wait(seconds: number?) -> number

Legacy global alias for task.wait; yields the calling coroutine until seconds have elapsed and returns the elapsed time.

wait(0.5)
print("half a second passed")

spawn(fn: function, ...: any) -> thread

Legacy global alias for task.spawn; creates and immediately resumes a new coroutine running fn.

spawn(function() print("legacy spawn") end)

tick() -> number

Returns the current Unix time as a floating point number of seconds with microsecond precision.

local t0 = tick()
print("now", t0)

Enum.<EnumType>.<Name> : EnumItem

Global table of Roblox-mirror enums. Each Enum.Type.Name is an EnumItem exposing .Name, .Value, and .EnumType.

print(Enum.Material.Plastic.Name, Enum.Material.Plastic.Value)
part.Material = Enum.Material.Neon