Skip to Content

Globals

Globals and standard libraries available to every script without GetService.

Cube3D globals

NameDescription
gameRoot object. Services are accessed with game:GetService(name). See game.
scriptThe executing script object. Exposes Name, Parent and child values.
taskTask scheduler: yielding, deferred and concurrent execution.
sharedTable shared by every script in the same context (server or client).
Vector3Vector type. See Vector3.
Color3Color type. See Color3.

task

FunctionDescription
task.wait(seconds)Yields the current task. With no argument it yields for one frame.
task.delay(seconds, fn, ...)Schedules fn to run after seconds without yielding the current task.
task.spawn(fn, ...)Runs fn immediately in a new task.
task.delay(5, function()
	print("Five seconds later")
end)

task.spawn(function()
	while true do
		task.wait(1)
		print("tick")
	end
end)

print("This prints first")

script

MemberDescription
script.NameScript name.
script.ParentContaining part, model or tool, or nil.
script:FindFirstChild(name)Returns the child value with the given name, or nil.
script:GetChildren()Returns the script's child values.
script.ValueNameShorthand for script:FindFirstChild("ValueName").

shared

shared is a single table readable and writable by every server script. Each client has a separate shared table for its client scripts.

shared.coins = shared.coins or {}
shared.coins[player.UserId] = 10

Lua basics

NameNotes
print, warn, error, assertprint and warn write to Output.
type, typeoftypeof also returns Cube3D type names such as "Vector3", "Part" and "Player".
tostring, tonumber
pairs, ipairs, next, select, unpack
pcall, xpcallProtected calls.
setmetatable, getmetatable, rawget, rawset, rawequal, rawlen

Libraries

LibraryFunctions
mathabs, ceil, floor, sqrt, sin, cos, tan, asin, acos, atan, exp, log, fmod, modf, min, max, random, randomseed, tointeger, type, rad, deg, clamp, round, sign, lerp, pi, huge
stringlen, sub, upper, lower, rep, reverse, byte, char, format, find, match, gmatch, gsub
tableinsert, remove, concat, sort, unpack, pack, clear, find
ostime, clock

String functions are also available as methods, for example ("hello"):upper().

On this page