Scene
Client
Server
Methods
number GetTime()
Simulation time in seconds; use this instead of the sandboxed os.time.
number GetDeltaTime()
Time passed since the last Update() call. Since time between updates is not constant use this to adjust changes such as movement according to the amount of time that has passed
function self:Update()
local speed = 10
local move = Vec3.right
--remember to multiply by delta time, since the time passed between each Update() is not constant
self.obj.pos = self.obj.pos + move * speed * Scene:GetDeltaTime()
end
number GetDebugTime()
High-resolution wall-clock time in seconds, for measuring real-time differences.
integer GetCurrentFrame()
string GetProcessState()
What is currently being processed i.e Start, Update, LateUpdate etc.
Object CreateObject(string? name, Object? parentObj)
Create an object on server or client. The object is not automatically synced to clients unless its set to. For naming we recommend to:
- Use capital case
- Use spaces between words
- If the object only holds a script component, name the object after the script
- Avoid creating multiple objects with the same name (i.e. by numbering them)
- If the object somehow belongs to a player include the user ID in the name
local ob = Scene:CreateObject("Player Controller 1")
Also see Scene:MakeNameValid
Object CreateObject(string name, Object? parentObj, boolean active, boolean save)
Object CreateObject(string name, boolean active, boolean save)
nil DestroyObject(Object obj)
Flags the object for deletion. The object will not actually be destroyed until the next frame.
Object[] GetObjectsByName(string name)
Object? GetObjectByName(string name)
Object? GetObjectById(string id)
Component? GetComponentById(string id)
boolean IsComponentOnePerObject(string typeName)
VoxelData? GetStaticVoxelData()
Object[] GetRootObjects()
Object[] GetAllObjects()
table[] GetMissingAssetRefs()
Object CloneObject(Object obj)
Object CloneObject(Object obj, Object intoObj)
Object CloneObject(Object obj, string name)
Object CloneObject(Object obj, boolean setSaveToFalse)
Object CloneObject(Object obj, string name, boolean setSaveToFalse)
boolean MoveObject(Object obj, Object newParentObj)
boolean MoveObjectAfter(Object obj, Object siblingObj)
boolean MoveObjectBefore(Object obj, Object siblingObj)
boolean MoveObjectToRoot(Object obj)
boolean CanMoveObject(Object obj, Object newParentObj)
Camera? GetActiveCamera()
Returns the currently active (rendering) camera, falling back to the first active camera found in the hierarchy. Nil when the scene has none.
nil SetActiveCamera(Camera cam)
Makes the given camera the active view.
VoxelDB? GetVoxelDB(string name)
nil ClearNormals(VoxelData vd)
boolean IsNameValid(string name)
string MakeNameValid(string name)
table GetLogCounters()
nil ResetLogCountersDif()
boolean ResetPrefab(Object obj)
nil UnpackPrefab(Object obj)
nil RebuildLighting()
nil CreateLighting(string type, string algo)
boolean GetProfileScriptsUpdate()
nil SetProfileScriptsUpdate(boolean value)
Enables or disables collection of the per-script Update timings read by GetScriptsProfiling. Toggling it off only stops collection — the accumulated avg/max survive until cleared by Server:LuaReset().
table GetSimpleStats()
table GetVDRStats()
table GetScriptsProfiling()
Returns an array of per-script-type rows (summed across all instances of that script), each row being {name, time, avg, max, cnt}:
| Field | Meaning |
|---|---|
name | Script type name |
time | Time in the last frame (µs) |
avg | Running average per frame (µs) — use this for stable readings |
max | Worst single frame (µs) |
cnt | Number of live instances of this script |
All times are in microseconds (may come back as comma-formatted strings — parse with tonumber((tostring(v):gsub(",","")))). Collection must first be enabled with SetProfileScriptsUpdate(true), otherwise the rows stay empty/stale. Only time spent inside Update/LateUpdate is counted — work in RPC handlers, event listeners, and Attach/Start is not attributed here.