Skip to content

Entity

Class · server and client scripts

Entity is a node in the scene tree: a part, a light, a sound, a character or a user interface element. It has a name, a parent, children and the values of its components.

Reading a name on an entity returns its property, method or component. A name that matches nothing is an error. Find a child with entity:Find(name) once when the script loads and keep the reference. Use entity:WaitFor(name) for a child that a client receives after the script starts.

See calling engine functions, engine errors, entity properties and components and network authority and replication; see input entities for the properties of InputContext, InputAction and InputBinding.

Pass Entity.NameChanged, Entity.ParentChanged, Entity.VisibleChanged or Entity.ActiveChanged to an entity's On method to run a handler once per frame in which that value of the entity changed; the handler gets no arguments. Entity.Destroyed runs a handler with no arguments once after the entity is destroyed: after the script step that destroyed it, and at the latest at the start of the next frame. The entity is dead when the handler runs, so use it to clean up what the script keeps about the entity. A script's connections end when the script's own entity is destroyed, so self:On(Entity.Destroyed, ...) never runs; connect it from another script, such as the one that spawned the entity.

Example

-- Server script in a part.
local coin = World.Spawn({ Shape = "Box" })
coin:On(Entity.Destroyed, function()
    print("coin removed")
end)
coin:Destroy()

ChildAdded

EventRead only
ChildAdded: Signal<(child: Entity) -> ()>

ChildAdded fires with the child when an entity becomes a direct child of this one: a new entity, a moved one, a clone or a child that replicates from the server. Deeper descendants do not fire it.

Example

-- Server script in a part.
self:On(Entity.ChildAdded, function(child: Entity)
    print("added " .. child.Name) -- prints added Lamp
end)
local lamp = World.Spawn({ Shape = "Box" })
lamp.Name = "Lamp"
lamp.Parent = self

ChildRemoved

EventRead only
ChildRemoved: Signal<(child: Entity) -> ()>

ChildRemoved fires with the child when a direct child moves to another parent or is destroyed. A destroyed child cannot be indexed, but it is still the same table key, so a script can use it to clean up.

Example

-- Server script in a part.
local lamp = World.Spawn({ Shape = "Box" })
lamp.Name = "Lamp"
lamp.Parent = self

self:On(Entity.ChildRemoved, function(child: Entity)
    print(child == lamp) -- prints true
end)
lamp:Destroy()

Clone

Method
Clone() -> Entity

Clone returns a copy of the entity and all its descendants. The copy has a new id and no parent until you set one.

Effects

  • The copy keeps the components and tags of the original and runs its own copy of every script attached to it, with self set to the copy. A script that clones the part it runs on therefore also runs in the clone and clones again.
  • A cloned character belongs to no player, and player.Avatar stays on the original.

Example

-- Server script in a part.
local crate = World.Spawn({ Shape = "Box" })
crate.Name = "Crate"
crate.Parent = World

local copy = crate:Clone()
copy.Parent = World
local pos = crate.Position
if pos then
    copy.Position = pos + Vector3.new(0, 5, 0)
end
print(copy.Name, copy == crate) -- prints Crate false

Destroy

Method
Destroy() -> ()

Destroy deletes the entity and all its descendants at once and disconnects their signal connections. It does nothing on an entity that is already destroyed.

Example

-- Server script in a part.
local bullet = World.Spawn({ Shape = "Box" })
bullet.Parent = World
task.delay(2, function()
    bullet:Destroy()
    print(bullet:IsAlive()) -- prints false
end)

Emit

Method
Emit(name: string, ...any) -> ()

Emit fires the named custom signal on this entity, passing any extra arguments to connected handlers.

Example

-- Server script in a part.
local box = World.Spawn({ Shape = "Box" })
box:GetSignal("Scored"):Connect(function(points: number)
    print(points)
end)
box:Emit("Scored", 10)

GetSignal

Method
GetSignal(name: string) -> Signal<...any>

GetSignal returns the named custom Signal on this entity, creating it on first use. Fire it with Emit.

Example

-- Server script in a part.
local box = World.Spawn({ Shape = "Box" })
local sig = box:GetSignal("Ping")
sig:Connect(function(msg: string)
    print(msg)
end)
box:Emit("Ping", "ready")

InputMove

PropertyClient only
InputMove: boolean

InputMove lets the local character walk and jump with the movement keys, the left stick and an InputAction that Drives "Move" or "Jump". It works only on the client's default camera, World.Viewport.Camera, which starts with it true.

Default false

InputSteer

PropertyClient only
InputSteer: boolean

InputSteer lets the mouse, the camera keys, the right stick and touch steer the CameraOrbit or CameraFly rig on this camera. The default camera starts with it true; set it to false to steer the rig from a script alone.

Default false

IsAlive

Method
IsAlive() -> boolean

IsAlive returns true until the entity is destroyed, then false.

Example

-- Server script in a part.
local coin = World.Spawn({ Shape = "Box" })
coin.Parent = World
coin:Destroy()
print(coin:IsAlive()) -- prints false

IsDescendantOf

Method
IsDescendantOf(ancestor: Entity | World) -> boolean

IsDescendantOf returns true when the entity is below ancestor in the tree. Every live entity is a descendant of World; a destroyed one is a descendant of nothing.

Example

-- Server script in a part.
local box = World.Spawn({ Shape = "Box" })
box.Parent = self
print(box:IsDescendantOf(self)) -- prints true
print(box:IsDescendantOf(World)) -- prints true
box:Destroy()
print(box:IsDescendantOf(World)) -- prints false
Errors (1)
Error When
'IsDescendantOf' is client-only; only client scripts may write it Written from a server script.

Name

Property
Name: string

Name is the name of this entity in the scene tree, at most 65535 bytes.

Default ""

Parent

Property
Parent: Entity?

Parent is the parent of this entity, or World for an entity at the top of the place, including a spawned character. Assign World to move an entity to the top. A destroyed entity reads nil, and writing its Parent is an error; iterate Players.All to inspect live player characters.

Effects

  • The entity keeps its world position and rotation; its local offset changes to match the new parent.
  • Assigning nil is an error; assign World to move an entity to the top.

Example

-- Server script in a part.
local lamp = World.Spawn({ Shape = "Box" })
lamp.Parent = self
lamp.Parent = World -- moves it to the top of the place
print(lamp.Parent == self) -- prints false

ViewSource

PropertyClient only
ViewSource: Entity?

ViewSource is the camera whose view World.Viewport.Screen shows, or nil for none.

Default nil

AeroSurface

Area

Property
Area: number

Area is the wing area in square units. Every physics step, lift is 0.5 * 0.00129 * Area * speed ^ 2 * C_L (with fixed air density 0.00129) and drag is the same with C_D. speed is only the airflow across the span (the part's X axis); the chord runs along -Z and lift acts toward the part's +Y. On an assembly member the forces push the whole assembly.

Default 1

Example

-- Server script in a flat wing part, so it glides instead of dropping.
self.Size = Vector3.new(8, 0.2, 2)
self:Add(Component.AeroSurface)
local aero = self.AeroSurface
if aero then
    aero.Area = 16
end
self.Velocity = Vector3.new(0, 0, -60)

CenterOfPressure

Property
CenterOfPressure: vector

CenterOfPressure is the point where lift and drag act, in the part's frame relative to its position. An offset from the center of mass makes lift and drag turn the body.

Default Vector3.new(0, 0, 0)

InducedDragFactor

Property
InducedDragFactor: number

InducedDragFactor is the drag coefficient a wing adds per squared lift coefficient: C_D = ZeroLiftDrag + InducedDragFactor * C_L ^ 2.

Default 0.3183

LiftSlope

Property
LiftSlope: number

LiftSlope is the lift coefficient a wing gains per radian of angle of attack (the angle between the airflow and the chord): C_L = LiftSlope * math.rad(angle) up to StallAngle (which is in degrees).

Default 6.28

StallAngle

Property
StallAngle: number

StallAngle is the angle of attack in degrees past which a wing's lift coefficient stops growing.

Default 15

ZeroLiftDrag

Property
ZeroLiftDrag: number

ZeroLiftDrag is a wing's drag coefficient when it makes no lift.

Default 0.02

Animator

ActiveAnimation

Method
ActiveAnimation() -> string?

ActiveAnimation returns the name of the clip the character plays, or nil when it plays none. At API 58 read Animator.ActiveClip.

Example

-- Server script.
local npc = assert(Prefabs.Spawn("Character"))
task.wait()
local animator = assert(npc.Animator)
animator:Play("sit")
task.wait(0.5)
print(animator.ActiveClip) -- prints sit

AnimLayers

PropertyRead only
AnimLayers: AnimLayers

AnimLayers lists the animation layers that blend together on this character. At API 58 use Animator.Layers.

The engine owns the layers below Animation.FirstScriptLayer; scripts set layers from Animation.FirstScriptLayer to 8. An unused layer reads nil, and assigning nil clears it.

A layer is a table with a Clip name and the optional fields Time in seconds (default 0), Weight from 0 to 1 (default 1), Speed from 0 to 2.55 (default 1), Mask, the Animation.Part bits of the limbs the layer moves or 0 for the whole body (default 0), and the booleans Loop and Additive (default false).

Example

-- Server script: blend a looping climb into a character's pose for 2 s.
local npc = assert(Prefabs.Spawn("Character"))
task.wait()
local layers = assert(npc.Animator).Layers
local layer = Animation.FirstScriptLayer
layers[layer] = { Clip = "climb", Weight = 0.5, Loop = true }
task.wait(2)
layers[layer] = nil

AnimationWeight

Method
AnimationWeight(clip: string) -> number?

AnimationWeight returns how much of the character's pose a clip makes up, from 0 to 1, or nil when no clip has that name. At API 58 call Animator:ClipWeight.

Example

-- Server script.
local npc = assert(Prefabs.Spawn("Character"))
task.wait()
local animator = assert(npc.Animator)
animator:Play("sit")
task.wait(1)
print(animator:ClipWeight("sit")) -- prints 1

AutoLocomotion

Property
AutoLocomotion: boolean

AutoLocomotion plays the character's walk, idle and jump animations from how it moves. It needs CharacterAnimation.

Default false

CharacterAnimation

Property
CharacterAnimation: boolean

CharacterAnimation animates the body parts under the character root. A part without BodyPart is not animated: it moves with the torso and never collides with it.

Without CharacterAnimation, each limb keeps the offset on the torso that Studio's move and rotate tools gave it, so a place can pose a character without a script. Turning it off in play leaves the limbs in their last pose.

Default false

MarkerReached

EventRead only
MarkerReached: Signal<(clip: string, marker: string) -> ()>

MarkerReached fires when an animation playing on this character passes a named marker. The callback receives the clip name and the marker name.

Markers come from the extras.markers list of the glTF take a clip was imported from: up to 16 entries with a name and a time in seconds. Only clients load clip assets, so only client scripts see markers from clip assets.

Example

-- Client script: print each marker that a character's clips pass.
Component.Animator.Added:Connect(function(character: Entity)
    character:On(Component.Animator.MarkerReached, function(clip: string, marker: string)
        print(clip, marker)
    end)
end)

PlayAnimation

Method
PlayAnimation(clip: string, fade: number?, speed: number?) -> ()

PlayAnimation plays a clip on the character in place of its walk, idle and jump animations, until StopAnimation. fade is the blend time in seconds and defaults to the walk fade; speed multiplies the playback rate and defaults to 1. At API 58 call Animator:Play.

Example

-- Server script.
local npc = assert(Prefabs.Spawn("Character"))
task.wait() -- a new character gets its animator at the next physics step
assert(npc.Animator):Play("sit", 0.2)

RootMotion

Property
RootMotion: boolean

RootMotion adds the root bone's movement in the playing clips to the character's horizontal velocity each frame. It needs Character.

Default false

StopAnimation

Method
StopAnimation(fade: number?) -> ()

StopAnimation stops the clips a script played and any preview, so the walk, idle and jump animations play again. fade is the fade-out time in seconds. At API 58 call Animator:Stop.

Example

-- Server script: sit for 3 seconds.
local npc = assert(Prefabs.Spawn("Character"))
task.wait()
local animator = assert(npc.Animator)
animator:Play("sit")
task.wait(3)
animator:Stop(0.2)
Errors (1)
Error When
'StopAnimation' is runtime state; only a server script writes it Written from a client script.

Atmosphere

BackgroundColor

Property
BackgroundColor: vector

BackgroundColor is the sRGB color behind everything when the Environment has no AtmosphereSky, PanoramaSky or SixSidedSky; the Default below is that color. On a user interface element it is the fill color of the element's background, which the Panel component stores, and it starts at Vector3.new(0.64, 0.64, 0.66).

Default Vector3.new(0.25, 0.29, 0.38)

BackgroundEnergyMultiplier

Property
BackgroundEnergyMultiplier: number

BackgroundEnergyMultiplier is the brightness, from 0 to 16, of the background color and of panorama and six-sided skies. The atmosphere sky ignores it.

Default 1

Panorama

Property
Panorama: string

Panorama is the asset id of a sky texture: a 2:1 equirectangular panorama or a cube texture. "0", or a texture that fails to load, shows BackgroundColor. AtmosphereSky draws instead when the entity has it.

Default "0"

PanoramaEnergyMultiplier

Property
PanoramaEnergyMultiplier: number

PanoramaEnergyMultiplier is the brightness of a panorama sky, from 0 to 128, multiplied by BackgroundEnergyMultiplier.

Default 1

PanoramaRotation

Property
PanoramaRotation: number

PanoramaRotation turns a panorama sky around the horizon, in degrees from 0 to 360.

Default 0

SkyboxBk

Property
SkyboxBk: string

SkyboxBk is the asset id of the back face (+Z) of a six-sided sky. If every face is "0" or any face fails to load, the sky shows BackgroundColor. AtmosphereSky and PanoramaSky draw instead when the entity has either.

Default "0"

SkyboxDn

Property
SkyboxDn: string

SkyboxDn is the asset id of the bottom face (-Y) of a six-sided sky.

Default "0"

SkyboxEnergyMultiplier

Property
SkyboxEnergyMultiplier: number

SkyboxEnergyMultiplier is the brightness of a six-sided sky, from 0 to 128, multiplied by BackgroundEnergyMultiplier.

Default 1

SkyboxFt

Property
SkyboxFt: string

SkyboxFt is the asset id of the front face (-Z) of a six-sided sky.

Default "0"

SkyboxLf

Property
SkyboxLf: string

SkyboxLf is the asset id of the left face (-X) of a six-sided sky.

Default "0"

SkyboxRotation

Property
SkyboxRotation: number

SkyboxRotation turns a six-sided sky around the horizon, in degrees from 0 to 360.

Default 0

SkyboxRt

Property
SkyboxRt: string

SkyboxRt is the asset id of the right face (+X) of a six-sided sky.

Default "0"

SkyboxUp

Property
SkyboxUp: string

SkyboxUp is the asset id of the top face (+Y) of a six-sided sky.

Default "0"

Billboard

BillboardColor

Property
BillboardColor: vector

BillboardColor is the text color of the camera-facing 3D billboard label.

Default Vector3.new(1, 1, 1)

BillboardMaxDistance

Property
BillboardMaxDistance: number

BillboardMaxDistance is how far from the camera, in world units, the billboard text shows; it fades out near this distance. 0 shows it at any distance.

Default 0

BillboardOffset

Property
BillboardOffset: vector

BillboardOffset is the center of the billboard text, in world units from the entity's position.

Default Vector3.new(0, 0, 0)

BillboardOnTop

Property
BillboardOnTop: boolean

BillboardOnTop, when true, draws the billboard text in front of everything.

Default false

BillboardScreenSize

Property
BillboardScreenSize: number

BillboardScreenSize is the part of the text height in screen points, the same at any distance. It adds to BillboardWorldSize.

Default 20

BillboardText

Property
BillboardText: string

BillboardText is the text of the camera-facing 3D billboard label. An empty string hides the label.

Default ""

BillboardViewerDistance

Property
BillboardViewerDistance: number

BillboardViewerDistance is how far from the viewer's character, in world units, the billboard text shows; it fades out over the last 30% of the range. With no character, the camera is the viewer. 0 shows it at any distance.

Default 0

Errors (1)
Error When
'BillboardViewerDistance' is client-only; only client scripts may call it Called from a server script.

BillboardWorldSize

Property
BillboardWorldSize: number

BillboardWorldSize is the part of the text height in world units, which looks smaller farther away. It adds to BillboardScreenSize.

Default 0

Border

BorderColor

Property
BorderColor: vector

BorderColor is the color of the border around the element.

Default Vector3.new(0, 0, 0)

BorderFocusOnly

Property
BorderFocusOnly: boolean

BorderFocusOnly, when true, draws the border only while a text box on or inside the element is typed in or is Input.Selected. That text box then draws no selection ring, so a search field shows one outline around the whole field.

Default false

BorderSizePixel

Property
BorderSizePixel: number

BorderSizePixel is the width in pixels of the border, drawn inside the element's edges; 0 draws none.

Default 1

BorderTransparency

Property
BorderTransparency: number

BorderTransparency is the transparency of the border, from 0 (opaque) to 1 (invisible).

Default 0

Box

AnchorPoint

Property
AnchorPoint: Vector2 | vector

AnchorPoint is the point of the element that its position places, as a fraction of its size: (0, 0) is the top left, (0.5, 0.5) the center and (1, 1) the bottom right.

Default Vector2.new(0, 0)

AspectRatio

Property
AspectRatio: number

AspectRatio is the element's width divided by its height; 0 keeps the shape that Size gives. The element takes the largest box of this ratio that fits in its Size, so Size = UIVector.fromScale(0.2, 0.2) with AspectRatio = 1 is a square on any screen.

Default 0

ClipsDescendants

Property
ClipsDescendants: boolean

ClipsDescendants, when true, cuts off the elements under this one at its edges.

Default false

Disabled

Property
Disabled: boolean

Disabled, when true, dims the element and stops it from taking the pointer, so no hover, click or activation events fire.

Default false

GroupTransparency

Property
GroupTransparency: number

GroupTransparency fades the element and every element under it, from 0 (as authored) to 1 (invisible), including an open popup, menu, dropdown panel or dialog. On a SurfaceCanvas or BillboardCanvas it fades the whole canvas. An element that takes the pointer still does at 1; set Visible to false to stop it.

Default 0

LayoutOrder

Property
LayoutOrder: number

LayoutOrder is the order of an element among its siblings in a list or grid: lower numbers come first, and equal numbers keep the order they were added in.

Default 0

MaxSize

Property
MaxSize: UIVector

MaxSize is the largest size layout gives the element; zero sets no limit. MinSize wins when it is larger.

Default UIVector.Zero

MinSize

Property
MinSize: Vector2 | vector

MinSize is the smallest width and height in pixels layout gives the element; a zero side sets no minimum. It wins over MaxSize.

Default Vector2.new(0, 0)

SizeModeX

Property
SizeModeX: SizeMode

SizeModeX is how the element's width is set. "Fixed" uses Size.X, "Fit" fits the width to the children, and "Grow" fills the room the parent gives, shared among a list's "Grow" children.

Default "Fixed"

SizeModeY

Property
SizeModeY: SizeMode

SizeModeY is how the element's height is set, as SizeModeX sets the width.

Default "Fixed"

UIRoot

Property
UIRoot: boolean

UIRoot, when true, makes the element the top of its own screen layer. An element under World.Viewport.Screen draws only when it or an ancestor below World.Viewport.Screen has UIRoot set to true.

Default false

Visible

Property
Visible: boolean

Visible is whether a UI element and everything under it show and take the pointer. Visible = false on a SurfaceCanvas or BillboardCanvas hides its whole canvas, and on Handles it hides the handles and lets the pointer through. On any other entity, Visible is the opposite of RenderDisabled, so Visible = false hides the entity and everything under it.

Default true

ZIndex

Property
ZIndex: number

ZIndex is which of overlapping siblings draws on top: higher numbers draw in front, and equal numbers draw in tree order, later siblings on top.

Default 0

ScreenPosition

PropertyRead only
ScreenPosition: Vector2

ScreenPosition is the laid-out top-left position of the element on screen, in UI points.

ScreenSize

PropertyRead only
ScreenSize: Vector2

ScreenSize is the laid-out width and height of the element on screen, in UI points.

Selectable

Property
Selectable: boolean

Selectable, when true, lets the arrow keys, d-pad and left stick move the selection onto the element. When it is false, the pointer can still press it.

Default true

SelectionChanged

EventRead only
SelectionChanged: Signal<(selected: boolean) -> ()>

SelectionChanged fires on the client when this control gains or loses the keyboard and gamepad selection, Input.Selected. The callback receives true when the control becomes selected and false when the selection leaves it.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = { Text = "Play" }, Button = true })
button.Parent = screen
button:On(Component.Box.SelectionChanged, function(selected)
    local panel = button.Panel
    if panel then
        panel.Color = Color.new(1, 1, 1, if selected then 1 else 0.5)
    end
end)
Input.Selected = button

SelectionGroup

Property
SelectionGroup: boolean

SelectionGroup, when true, keeps the arrow keys, d-pad and left stick from moving the selection out of this container, so a player in an inventory window cannot step onto the hotbar behind it. A script write to Input.Selected can still select outside it.

Default false

SelectionRing

Property
SelectionRing: boolean

SelectionRing, when true, draws the blue ring around the element while it is selected. False leaves the selected look to the element, which can draw it from SelectionChanged.

Default true

Button

ArrowDirection

Property
ArrowDirection: string

ArrowDirection is the direction the button's arrow points: "Left", "Right", "Up" or "Down".

Default "Right"

Clicked

PropertyRead only
Clicked: ComponentSignal<Entity>

Clicked fires when a player activates this button with a pointer click, touch tap, or gamepad/keyboard confirmation, passing the local player's character entity.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = { Text = "Go" }, Button = true })
button.Parent = screen

button:On(Component.Button.Clicked, function()
    print("clicked")
end)

Cursor

Property
Cursor: CursorShape

Cursor is the cursor shape shown while the pointer is over the element. It takes a CursorShape name, such as "Pointer" or "Text". "Auto" uses the nearest ancestor's cursor.

Default "Auto"

DragEnded

EventRead only
DragEnded: Signal<(edited: boolean) -> ()>

DragEnded fires on the client when the player finishes dragging this control. It passes true if the drag changed the control's value.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = {}, Button = true })
button.Parent = screen

button:On(Component.Button.DragEnded, function()
    print("drag ended")
end)

Dragged

PropertyRead only
Dragged: ComponentSignal<Entity, Vector2>

Dragged fires on the client while a pointer drags this control. It passes the button entity and the pointer movement delta as a Vector2 in UI points.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = {}, Button = true })
button.Parent = screen

button:On(Component.Button.Dragged, function(_entity: Entity, delta: Vector2)
    local box = button.Box
    if box then
        box.Position += UIVector.fromPoints(delta.X, delta.Y)
    end
end)

HoverChanged

PropertyClient onlyRead only
HoverChanged: ComponentSignal<boolean>

HoverChanged fires when the pointer enters or leaves this button, passing true on enter and false on leave.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = { Text = "Hover" }, Button = true })
button.Parent = screen

button:On(Component.Button.HoverChanged, function(hovered: boolean)
    print(hovered)
end)

LinkUrl

Property
LinkUrl: string

LinkUrl is the http:// or https:// address the button opens in the player's browser. Setting it underlines the button's text.

Default ""

Pressed

EventRead only
Pressed: Signal<(index: number?) -> ()>

Pressed fires on the client when a mouse button or touch goes down on this control. On an InputAction, it fires when one of its bindings starts the action.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = {}, Button = true })
button.Parent = screen

button:On(Component.Button.Pressed, function()
    print("down")
end)

Released

EventRead only
Released: Signal<(index: number?) -> ()>

Released fires on the client when a mouse button or touch comes up over this control. On an InputAction, it fires when the action ends.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = {}, Button = true })
button.Parent = screen

button:On(Component.Button.Released, function()
    print("up")
end)

RepeatDelay

Property
RepeatDelay: number

RepeatDelay is how many seconds a button or arrow key is held before it repeats every RepeatInterval.

Default 0.275

RepeatInterval

Property
RepeatInterval: number

RepeatInterval is the number of seconds between repeats while a button or key stays held.

Default 0.05

ShadeFill

Property
ShadeFill: boolean

ShadeFill, when true, lightens the fill of a clickable element under the pointer, and more while pressed.

Default false

WheelMoved

EventRead only
WheelMoved: Signal<(delta: number) -> ()>

WheelMoved fires on the client when the mouse wheel turns while the pointer is over this element or anything inside it. delta is the movement in notches, positive up, as Input.Scroll reports it; a touchpad reports fractions of a notch. Only the innermost element under the pointer with a connection fires: the camera does not zoom and Input.Scroll reads 0 for that update. Over a scrolling frame whose canvas is larger than the frame, or over a graph, the wheel scrolls or zooms it and WheelMoved does not fire.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local button = World.Spawn({ Box = {}, Panel = {}, UITextSource = { Text = "Page 1" }, Button = true })
button.Parent = screen

local page = 1
button:On(Component.Button.WheelMoved, function(delta)
    page = math.max(1, page + (delta < 0 and 1 or -1))
    local label = button.UITextSource
    if label then
        label.Text = "Page " .. page
    end
end)

Character

Character

PropertyRead only
Character: Entity?

Character is the character this entity is or controls: a player gives its character, a character root gives itself, a body part gives its character root, and any other entity gives nil.

A player has no character before its first spawn, and keeps a dead character until the new one spawns, so check State to know whether it is "Dead". To make an entity a character root, add Component.Character.

Example

-- Server script in a part: knock over any character that touches it.
self:On(Component.Collider.Touched, function(hit: Entity)
    local character = hit.Character
    if character and character.State ~= "Dead" then
        character:SetState("Ragdoll")
    end
end)

CharacterPhysics

Property
CharacterPhysics: boolean

CharacterPhysics gives the character root a physics body so the character moves under physics. The character controller also needs Locomotion; without it the entity is an ordinary physics body. The built-in character's torso is its "Torso" child, so World.Query(Component.BodyPart) lists that child and not the character root.

Default false

Example

-- Server script: make a block that walks like a character.
local mob = World.Spawn({
    Shape = "Box",
    Size = Vector3.new(2, 3, 2),
    CharacterPhysics = true,
    Locomotion = { WalkSpeed = 8 },
})
mob:Add(Component.Character)

CharacterSurfaceAlign

Property
CharacterSurfaceAlign: boolean

CharacterSurfaceAlign turns UpDirection toward the normal of the floor the character stands on, so it can walk up walls. It needs GravityVector.

Default false

GetStateEnabled

Method
GetStateEnabled(state: CharacterState) -> boolean

GetStateEnabled returns whether a character enters a movement state by itself. Every state is enabled until SetStateEnabled turns it off.

Example

-- Server script.
local npc = assert(Prefabs.Spawn("Character"))
local character = assert(npc.Character)
print(character:GetStateEnabled("Jumping")) -- prints true

GravityVector

Property
GravityVector: vector

GravityVector is the acceleration in units/s² that replaces world Gravity for this character.

Default Vector3.new(0, -196.2, 0)

NoContactFriction

Property
NoContactFriction: boolean

NoContactFriction makes the character's colliders slide with no friction.

Default false

SetStateEnabled

Method
SetStateEnabled(state: CharacterState, enabled: boolean) -> ()

SetStateEnabled sets whether a character enters a movement state by itself. With "Jumping" off it ignores the jump input; with "GettingUp" off a character in "Ragdoll" or "FallingDown" stays down. To keep a character from falling over, turn off both "Ragdoll", which a hard hit causes, and "FallingDown", which tipping too far causes.

character:SetState(...) still puts a character into a disabled state, and turning "Dead" off does not keep a character alive.

Example

-- Server script: a character carrying a crate cannot jump or fall over.
local npc = assert(Prefabs.Spawn("Character"))
local character = assert(npc.Character)
character:SetStateEnabled("Jumping", false)
character:SetStateEnabled("Ragdoll", false)
character:SetStateEnabled("FallingDown", false)

State

PropertyRead only
State: CharacterState?

State is what the character is doing: "Running", "FreeFall", "Jumping", "Climbing", "Swimming", "Seated", "Ragdoll", "FallingDown", "GettingUp", "Dead", "PlatformStanding" or "Physics".

A character swims when most of its body is in water (an anchored part whose material uses the water shader). Turn "Swimming" off with SetStateEnabled to make it walk along the bottom.

State is nil on a character root made with CharacterPhysics until the next physics step gives it a body.

Default "FreeFall"

Example

-- Server script: put a character into Ragdoll and read its state.
local npc = assert(Prefabs.Spawn("Character"))
local character = assert(npc.Character)
npc:On(Component.Character.State.Changed, function()
    print(character.State)
end)
character:SetState("Ragdoll")
print(character.State) -- prints Ragdoll

UpDirection

Property
UpDirection: vector

UpDirection is the direction the character stands along. Floor checks, jumps and the force that keeps it upright follow it.

Default Vector3.new(0, 1, 0)

AirAccelerate

Property
AirAccelerate: number

AirAccelerate is how fast the character speeds up in the air toward the movement keys, in multiples of WalkSpeed per second. Turning while strafing keeps adding speed.

Default 12

AirMaxWishSpeed

Property
AirMaxWishSpeed: number

AirMaxWishSpeed is the speed, in units/s, at which holding the movement keys in a straight line in the air stops adding speed. Strafing still builds speed past it.

Default 1.92

AutoRotate

Property
AutoRotate: boolean

AutoRotate turns the character to face the direction it walks. Shift lock turns it toward the camera direction instead.

Default false

HipHeight

Property
HipHeight: number

HipHeight is how high, in units, the bottom of the torso stands above the ground.

Default 2

JumpPower

Property
JumpPower: number

JumpPower is the speed, in units/s, a jump from the ground gives the character along UpDirection.

Default 50

JumpPowerScale

Property
JumpPowerScale: number

JumpPowerScale multiplies JumpPower for jumps in the air.

Default 1

MaxJumps

Property
MaxJumps: number

MaxJumps is how many times the character can jump in the air before it lands, 0 to 255. At 0, the character jumps only from the ground; setting MaxJumps to 1 enables a double jump (1 + MaxJumps total jumps).

Default 0

MaxSlopeAngle

Property
MaxSlopeAngle: number

MaxSlopeAngle is the steepest slope, in degrees, the character walks on. On steeper ground it cannot jump and, by default, slides down.

Default 89

WalkSpeed

Property
WalkSpeed: number

WalkSpeed is how fast the character walks, in units/s.

Default 16

CharacterRig

CharacterRig

Property
CharacterRig: boolean

CharacterRig gives the limbs physics bodies that follow the torso and the animation. It needs CharacterPhysics. The limbs collide only in the "Ragdoll", "FallingDown" and "Dead" states.

Default false

Climbable

Climbable

Property
Climbable: boolean

Climbable makes characters that walk into the part climb it, as on a ladder. A character climbs a moving ladder as if the ladder stood still and rides along when it holds still.

Default false

CollisionGroup

CollisionGroup

Property
CollisionGroup: string

CollisionGroup is the name of the collision group that decides what this part collides with. A group must be registered with Physics.RegisterCollisionGroup before a part can join it.

Default "Default"

Effects

  • On a character, every limb joins the group too.
  • A character follows its group's collision rules for walking, standing, stepping, climbing and swimming; when a rule against a part's group is false, the character walks and falls through that part.
  • "CharacterNoCollide" collides with "Default" by default, so characters in "CharacterNoCollide" stand on "Default" floors unless a script disables that rule.
  • A part parented under a character never collides with that character, and the character never stands on it.

Example

-- Server script in a floor part: ghost crates fall through it.
if self.Body then self.Body.Motion = "Static" end
Physics.RegisterCollisionGroup("Ghost")
Physics.SetCollides("Ghost", "Default", false)

local crate = World.Spawn({ Shape = "Box" })
crate.CollisionGroup = "Ghost"
crate.Position = Vector3.new(0, 10, 0)
crate.Parent = World
task.wait(2)
local pos = crate.Position
print(pos ~= nil and pos.Y < 0) -- prints true

Color

Color

Property
Color: Color

Color tints the part's base color, its mesh texture, or a decal's image. Color.White leaves the texture as it is and Color.Black makes it black.

Default Color.Black

Effects

  • Any write, black included, turns a mesh with a texture id such as Albedo into a clothing layer: the mesh file's textures are not used, and Underlay, then Albedo, blend over Color.

Transparency

Property
Transparency: number

Transparency is how see-through the surface is, from 0 (solid) to 1 (invisible). It does not change collisions or raycasts.

Default 0

ConsolePrompt

ConsolePrompt

Property
ConsolePrompt: boolean

ConsolePrompt, when true, makes this element the developer console command input.

Default false

ConsoleRowLine

Property
ConsoleRowLine: boolean

ConsoleRowLine, when true, makes this element show the text of a developer console message.

Default false

ConsoleRowPrefix

Property
ConsoleRowPrefix: boolean

ConsoleRowPrefix, when true, makes this element show the time or source of a developer console message.

Default false

Decal

Layer

Property
Layer: number

Layer orders decals on the same face of a part, from -128 to 127. A higher layer draws in front, but every layer at -1 or below draws as -1, and every layer at 2 or above as 2.

Default 0

Side

Property
Side: Face

Side is the face of the parent part that a decal shows on: "Right" (+X), "Top" (+Y), "Back" (+Z), "Left" (-X), "Bottom" (-Y) or "Front" (-Z). A parent with a mesh places the decal by the mesh's UVs.

Default "Front"

Texture

Property
Texture: string | DynamicImage | Entity

Texture is the asset id of the image a decal shows. "0" draws nothing. Color tints the image and Transparency fades it.

Default "0"

Example

-- Server script in a part: put a sign on its top face.
local sign = World.Spawn({ Decal = { Texture = "123456789", Side = "Top" } })
sign.Parent = self

DirectionalLight

DirectionalColor

Property
DirectionalColor: Color

DirectionalColor is the color tint of the sunlight. The light shines along the entity's Rotation; only the first directional light in the world lights the scene.

Default Color.White

DirectionalEnergy

Property
DirectionalEnergy: number

DirectionalEnergy is the brightness of the sunlight, from 0 to 20. At 0 surfaces get only ambient light.

Default 1

DirectionalShadowFill

Property
DirectionalShadowFill: number

DirectionalShadowFill is the share of diffuse sunlight that still reaches surfaces in the sun's shadow. 0 leaves shadows dark, and 1 lights them fully except for the sun's highlight.

Default 100/255

DirectionalShadowMode

Property
DirectionalShadowMode: "None" | "Hard"

DirectionalShadowMode is whether the sun casts shadows: "None" casts none, and "Hard" casts sharp-edged shadows out to MaxDistance from the camera.

Default "Hard"

MaxDistance

Property
MaxDistance: number

MaxDistance is how far from the camera, in units, the sun casts shadows.

Default 500

DisplayName

DisplayName

Property
DisplayName: string

DisplayName is the name on the character's nametag and in the player list.

Default ""

HingeJoint

ConnectedBody

Property
ConnectedBody: Entity?

ConnectedBody is the part this part is linked to by a hinge around HingeAxis at HingeAnchor. The hinge forms only between parts with physics bodies in different assemblies, and setting nil or destroying either part removes it.

Default nil

Example

-- Server script in a door frame part: hang a door on its left edge.
if self.Body then self.Body.Motion = "Static" end
local door = World.Spawn({ Shape = "Box", Body = {} })
door.Size = Vector3.new(4, 7, 0.2)
local pos = self.Position
if pos then
    door.Position = pos + Vector3.new(2, 0, 0)
end
door.Parent = World
door:Add(Component.HingeJoint)
local hinge = door.HingeJoint
if hinge then
    hinge.Anchor = Vector3.new(-2, 0, 0)
    hinge.Axis = Vector3.new(0, 1, 0)
    hinge.LimitsEnabled = true
    hinge.MinAngle = -90
    hinge.MaxAngle = 90
    hinge.Target = self
end

HingeAnchor

Property
HingeAnchor: vector

HingeAnchor is the pivot of the hinge, in units in this part's frame.

Default Vector3.new(0, 0, 0)

HingeAxis

Property
HingeAxis: vector

HingeAxis is the direction the hinge turns around, in this part's frame.

Default Vector3.new(1, 0, 0)

LimitsMax

Property
LimitsMax: number

LimitsMax is the upper angle limit of the hinge in degrees when UseLimits is true.

Default 0

LimitsMin

Property
LimitsMin: number

LimitsMin is the lower angle limit of the hinge in degrees when UseLimits is true.

Default 0

MotorForce

Property
MotorForce: number

MotorForce is the most torque in Newton-meters the hinge motor applies. At 0 the motor does not turn the part.

Default 0

MotorTargetVelocity

Property
MotorTargetVelocity: number

MotorTargetVelocity is the speed of the hinge motor in degrees per second. A positive value turns counterclockwise around HingeAxis.

Default 0

UseLimits

Property
UseLimits: boolean

UseLimits keeps the hinge angle between LimitsMin and LimitsMax. With both limits at their default of 0, the hinge does not turn.

Default false

UseMotor

Property
UseMotor: boolean

UseMotor turns the hinge at MotorTargetVelocity with up to MotorForce.

Default false

Example

-- Server script in a part: spin a platform on top of it a quarter turn per second.
if self.Body then self.Body.Motion = "Static" end
local top = World.Spawn({ Shape = "Box", Body = {} })
top.Size = Vector3.new(6, 0.5, 6)
local pos = self.Position
if pos then
    top.Position = pos + Vector3.new(0, 1.5, 0)
end
top.Parent = World
top:Add(Component.HingeJoint)
local hinge = top.HingeJoint
if hinge then
    hinge.Axis = Vector3.new(0, 1, 0)
    hinge.MaxMotorTorque = 10000
    hinge.MotorSpeed = 90
    hinge.Target = self
end

Image

DisabledImage

Property
DisabledImage: string | DynamicImage | Entity

DisabledImage is the asset id of the image shown in place of Image while the element or any ancestor is disabled. "0" keeps Image.

Default "0"

HoverImage

Property
HoverImage: string | DynamicImage | Entity

HoverImage is the asset id of the image shown in place of Image while the pointer is over the element and not pressing it. "0" keeps Image.

Default "0"

Image

Property
Image: string | DynamicImage | Entity

Image is the asset id of the image drawn over the element's box. "0" draws none.

Default "0"

ImageColor

Property
ImageColor: vector

ImageColor tints the image: each pixel is multiplied by this color.

Default Vector3.new(1, 1, 1)

ImageRectOffset

Property
ImageRectOffset: Vector2 | vector

ImageRectOffset is the top-left corner, in texture pixels, of the region of the texture the image shows. With ImageRectSize it picks one sprite of a sprite sheet.

Default Vector2.new(0, 0)

ImageRectSize

Property
ImageRectSize: Vector2 | vector

ImageRectSize is the size, in texture pixels, of the region of the texture the image shows. A zero side shows the whole texture.

Default Vector2.new(0, 0)

ImageRotation

Property
ImageRotation: number

ImageRotation turns the image clockwise by this many degrees about the element's center. Layout, clicks and children do not turn.

Default 0

ImageTransparency

Property
ImageTransparency: number

ImageTransparency is the transparency of the image, from 0 (opaque) to 1 (invisible).

Default 0

PressedImage

Property
PressedImage: string | DynamicImage | Entity

PressedImage is the asset id of the image shown in place of Image while the button is held down. "0" keeps Image.

Default "0"

ResampleMode

Property
ResampleMode: string

ResampleMode is how image pixels are sampled when the image draws larger or smaller than the texture: "Default" blends neighbors, and "Pixelated" keeps the square pixels of pixel art.

Default "Default"

ScaleType

Property
ScaleType: ImageScaleMode

ScaleType is how the image fills an element of a different size. "Stretch" scales it to the element, "Slice" keeps the corners at their size (see SliceCenter), "Tile" repeats it at TileSize, "Fit" fits it inside, and "Crop" covers the element and cuts the overflow.

Default "Stretch"

SliceCenter

Property
SliceCenter: Insets

SliceCenter is the stretching middle of a "Slice" image, in image pixels. The pixels outside Left, Top, Right, and Bottom are corners and edges that keep their size.

Default Insets.Zero

SliceScale

Property
SliceScale: number

SliceScale is the size of a "Slice" image's corners and edges as a multiple of their image size.

Default 1

TileSize

Property
TileSize: UIVector

TileSize is the size of one tile of a "Tile" image: the scale is a fraction of the element's size and the offset is pixels. A zero side draws one tile across that side.

Default UIVector.fromScale(1, 1)

InputAction

Drives

Property
Drives: InputActionDrives

Drives is the character control an InputAction drives, so a touch stick, a UI button, or a key can make the local character walk or jump. "Move" walks along an "Axis2" action's vector (+Y forward from the camera, its length the fraction of walk speed); "Jump" jumps while a "Button" action is held.

At API 58 configure InputAction fields (Kind: "Button", "Axis1", or "Axis2", Enabled, Replicated, Drives, and optional Deadzone in 0..0.95) and InputBinding on the action entity.

Default "None"

Effects

  • The action drives the character only while the escape menu is closed and Input.MoveCharacter is true.

Example

-- Client script: bind J to jump.
local controls = World.Spawn({ InputContext = { Priority = 1000 } })
local jump = World.Spawn({
    InputAction = { Kind = "Button", Drives = "Jump" },
    InputBinding = { Inputs = { "J" } },
})
jump.Parent = controls

GetState

MethodClient only
GetState() -> boolean | vector

At API 58 use the typed InputAction component view reads: action.InputAction:IsDown(player?), WasPressed(player?), and WasReleased(player?) for "Button" actions, GetAxis(player?) (-1..1) for "Axis1" actions, and GetVector(player?) (Vector2, length 0..1) for "Axis2" actions. Pass player on the server for a Replicated = true action; omit player or pass Players.Local on a client.

Example

-- Client script: print while the player holds Left Shift.
local gameplay = World.Spawn({ InputContext = { Priority = 1000 } })
local sprint = World.Spawn({
    InputAction = { Kind = "Button" },
    InputBinding = { Inputs = { "LeftShift", "ButtonL3" } },
})
sprint.Parent = gameplay

function Update(dt: number)
    local action = sprint.InputAction
    if action and action:IsDown() then
        print("sprinting")
    end
end

StateChanged

EventRead only
StateChanged: Signal<(state: boolean | vector) -> ()>

At API 58 subscribe to Component.InputAction.Pressed and Component.InputAction.Released for "Button" actions, which fire with (player: Entity) (Players.Local on a client, or the acting player on the server when Replicated = true). Read "Axis1" and "Axis2" actions each frame with GetAxis() and GetVector().

Example

-- Client script: report when the player presses and releases F.
local tools = World.Spawn({ InputContext = { Priority = 1000 } })
local flashlight = World.Spawn({
    InputAction = { Kind = "Button" },
    InputBinding = { Inputs = { "F" } },
})
flashlight.Parent = tools

flashlight:On(Component.InputAction.Pressed, function(player: Entity)
    print(player.Name .. " pressed")
end)
flashlight:On(Component.InputAction.Released, function(player: Entity)
    print(player.Name .. " released")
end)

InputBinding

Direction

Property
Direction: string

At API 58 Direction is replaced by the per-direction lists Up, Down, Left, Right, Inputs, Negative, and Stick on InputBinding (up to 16 entries total across those fields on one binding).

Down

Property
Down: string

Down is a list of InputName values (InputBinding.Down, {} by default) that add -1 on Y to an "Axis2" action while held.

Input

Property
Input: string

At API 58 Input is replaced by InputBinding.Inputs (a list of InputName values for "Button" or positive "Axis1"), InputBinding.Negative (negative "Axis1"), and InputBinding.Stick ("LeftStick" or "RightStick" for "Axis2").

KeyCode

Property
KeyCode: string

At API 58 KeyCode is replaced by InputBinding.Inputs (for "Button" and "Axis1") and InputBinding.Stick (for "Axis2" thumbsticks).

Keybind

Property
Keybind: string

Keybind follows a Settings.Keybind player action (such as "Jump" or "PlayerList") on a "Button" action so the player's rebinds apply automatically, or nil by default for none.

Example

-- Client script: react to the player's Player List keybind.
local keys = World.Spawn({ InputContext = { Priority = 1000 } })
local toggle = World.Spawn({
    InputAction = { Kind = "Button" },
    InputBinding = { Keybind = "PlayerList" },
})
toggle.Parent = keys

toggle:On(Component.InputAction.Pressed, function()
    print("toggle the player list")
end)

Left

Property
Left: string

Left is a list of InputName values (InputBinding.Left, {} by default) that add -1 on X to an "Axis2" action while held.

Property
Right: string

Right is a list of InputName values (InputBinding.Right, {} by default) that add +1 on X to an "Axis2" action while held.

UIButton

Property
UIButton: Entity?

UIButton is a UI button entity that presses a "Button" action while held or tapped, or a thumbstick button whose deflection drives an "Axis2" action; nil binds no button.

Default nil

Up

Property
Up: string

Up is a list of InputName values (InputBinding.Up, {} by default) that add +1 on Y to an "Axis2" action while held. The action sums its bindings and clamps length to 1, so W and D together read (0.707, 0.707).

Example

-- Client script: steer with WASD, arrow keys, or the left thumbstick.
local gameplay = World.Spawn({ InputContext = { Priority = 1000 } })
local steer = World.Spawn({
    InputAction = { Kind = "Axis2" },
    InputBinding = {
        Up = { "W", "ArrowUp" },
        Down = { "S", "ArrowDown" },
        Left = { "A", "ArrowLeft" },
        Right = { "D", "ArrowRight" },
        Stick = "LeftStick",
    },
})
steer.Parent = gameplay

function Update(dt: number)
    local action = steer.InputAction
    if action then
        local dir = action:GetVector()
        if dir.Magnitude > 0 then
            print(dir.X, dir.Y)
        end
    end
end

InputContext

Enabled

Property
Enabled: boolean

Enabled is whether this InputContext receives input. Turning off a context releases every held action under it. A client can override Enabled locally with Override.

Default true

Priority

Property
Priority: number

Priority is the order in which InputContext entities receive input, highest first. Contexts with the same priority all receive the input.

Default 1000

SelectionScope

Property
SelectionScope: Entity?

SelectionScope is the UI element within which an InputContext is active: the context receives input only while Input.Selected is that element or inside it, or everywhere when nil. A scoped context receives input before every unscoped one, whatever their Priority.

Default nil

Effects

  • An inner SelectionGroup stops the scope, so a popup that has the selection turns off the keys of the list it opens from.
  • With Sink, the inputs its actions bind go to those actions instead of moving or activating the selection or opening the menu.

Sink

Property
Sink: boolean

Sink stops the inputs and UI buttons of an InputContext's enabled actions from reaching lower-priority contexts, built-in character controls, and Input.IsDown, WasPressed, WasReleased, GetHeld, Pressed, and Released.

Default false

Effects

  • When a context stops sinking a held key, the key reaches character controls and "Axis1" / "Axis2" actions without a new press, so a player holding W keeps walking. A "Button" action starts only on a new press.
  • While the escape menu is open, an enabled context with Sink still hides its inputs from built-in character controls.

Example

-- Client script: Space fires a jetpack instead of jumping.
local jetpack = World.Spawn({ InputContext = { Sink = true } })
local thrust = World.Spawn({
    InputAction = { Kind = "Button" },
    InputBinding = { Inputs = { "Space" } },
})
thrust.Parent = jetpack

thrust:On(Component.InputAction.Pressed, function()
    print("thrust")
end)

Lifetime

Remaining

Property
Remaining: number

Remaining is how many seconds are left before this entity and everything under it are destroyed. A client counts down only entities it made.

Default 0

Example

-- Server script: make a brick that disappears after 5 seconds.
local brick = World.Spawn({ Shape = "Box", Lifetime = 5 })

Light

InnerAngle

Property
InnerAngle: number

InnerAngle is the half-angle, in radians from 0 to 1.57, of the fully lit center of a spotlight. Between InnerAngle and OuterAngle the light fades to nothing.

Default 0.35

Intensity

Property
Intensity: number

Intensity is the brightness of a point light or spotlight, from 0 to 1000, multiplied by LightColor.

Default 75

LightColor

Property
LightColor: vector

LightColor is the sRGB color of a point light or spotlight.

Default Vector3.new(1, 1, 1)

LightShadowOff

Property
LightShadowOff: boolean

LightShadowOff, when true, stops a point light or spotlight from casting shadows. At most 4 point lights and 8 spotlights cast shadows in a frame; the others light without them.

Default false

OuterAngle

Property
OuterAngle: number

OuterAngle is the half-angle, in radians from 0 to 1.57, of a spotlight's cone, which points along the entity's -Y axis.

Default 0.5

Example

-- Server script in a part: a warm spotlight that points down.
local light = self:Add(Component.Light)
light.LightColor = Color.new(1, 0.8, 0.5)
self:Add(Component.SpotCone).OuterAngle = math.rad(30)

Range

Property
Range: number

Range is how far, in units from 0 to 1000, a point light or spotlight reaches. The light fades to nothing at Range.

Default 100

LocalSpin

LocalSpin

Property
LocalSpin: vector

LocalSpin is the angular velocity in radians per second of an assembly member around its parent part, in that parent's frame. The server turns the member every physics step and clients turn it from the rate, so a fan or wheel spins smoothly. If a script writes the rotation every step instead, the part looks slower or reversed on clients above 1800 rpm.

Default Vector3.new(0, 0, 0)

Example

-- Server script in a fan blade inside an assembly Model.
self.LocalSpin = Vector3.new(0, 2 * math.pi, 0) -- one turn per second

Mesh

Mesh

Property
Mesh: string

Mesh is the asset id of a 3D model drawn at the part's Size in place of its Type shape. "0" draws the shape.

Default "0"

Panel

BackgroundTransparency

Property
BackgroundTransparency: number

BackgroundTransparency is the transparency of the element's background, from 0 (opaque) to 1 (invisible).

Default 0

CornerRadii

Property
CornerRadii: Insets

CornerRadii is the radius in pixels of each corner of the background: Left and Top are top-left and top-right, and Right and Bottom are bottom-right and bottom-left. When all four are 0, CornerRadius applies.

Default Insets.Zero

CornerRadius

Property
CornerRadius: number

CornerRadius is the radius in pixels of the corners of the background and border, never more than half the element's width or height.

Default 0

PbrMaterial

Albedo

Property
Albedo: string | DynamicImage | Entity

Albedo is the asset id of the texture that gives a mesh its base colors, along the mesh's UV coordinates. "0" shows the part's Color or its material's textures.

Default "0"

Emissive

Property
Emissive: string | DynamicImage

Emissive is the asset id of a texture that makes parts of a mesh glow in any light; black gives no glow. "0" means none.

Default "0"

MetallicRoughness

Property
MetallicRoughness: string | DynamicImage

MetallicRoughness is the asset id of a texture whose blue channel sets metalness and green channel sets roughness. Metalness 1 looks like bare metal; low roughness is shiny and high roughness is matte. "0" uses the material's own settings.

Default "0"

Normal

Property
Normal: string | DynamicImage

Normal is the asset id of a tangent-space normal map, with green pointing up the image as in glTF, so bumps and grooves show without more polygons. "0" lights the mesh by its own faces.

Default "0"

Occlusion

Property
Occlusion: string | DynamicImage

Occlusion is the asset id of an ambient occlusion texture. Its red channel darkens the ambient light and the shadow fill in creases; local lights are not affected. "0" means none.

Default "0"

Underlay

Property
Underlay: string | DynamicImage

Underlay is the asset id of a second texture drawn under Albedo and over the surface color. It draws only when the entity has its own Color, is a character part with a body color, or has a mesh file that colors the sub-mesh. "0" means none.

Default "0"

Options

Property
Options: string

Options is the choices of a dropdown, separated by commas. The chosen entry is the one at SelectedIndex.

Default ""

Property
Popup: boolean

Popup, when true, closes the popup when the player clicks outside it.

Default false

PopupOpen

Property
PopupOpen: boolean

PopupOpen, when true, shows the popup panel above the rest of the interface.

Default false

Position

LocalPosition

Property
LocalPosition: vector

LocalPosition is the offset of the entity from its nearest positioned ancestor, in units. Without a positioned ancestor, it is the last value written, or (0, 0, 0), and a write does not move the entity.

Default Vector3.new(0, 0, 0)

Example

-- Server script in a part.
local lamp = World.Spawn({ Shape = "Box" })
lamp.Parent = self
lamp.LocalPosition = Vector3.new(0, 3, 0)

self.Position = Vector3.new(10, 0, 0)
local pos = lamp.Position
if pos then
    print(pos.Y) -- prints 3
end

LocalRotation

Property
LocalRotation: Rotation

LocalRotation is the rotation of the entity relative to its nearest positioned ancestor. Without a positioned ancestor, it is the last value written, or Rotation.Identity, and a write does not turn the entity.

Default Rotation.Identity

Example

-- Server script in a part.
local arm = World.Spawn({ Shape = "Box" })
arm.Parent = self
self.Rotation = Rotation.fromEuler(Vector3.new(0, 90, 0))
arm.LocalRotation = Rotation.fromEuler(Vector3.new(0, 45, 0))
local rot = arm.Rotation
if rot then
    print(math.round(rot:ToEuler().Y)) -- prints 135
end

Position

Property
Position: vector

Position is the position of the entity in the world, in units. Descendants move with it. On a user interface element, Position is a UIVector that places the element in its parent; read it typed through Box.

Default Vector3.new(0, 0, 0)

Example

-- Server script in a part with a light above it.
if self.Body then self.Body.Motion = "Static" end
local light = World.Spawn({ Shape = "Box" })
if light.Body then light.Body.Motion = "Static" end
light.Parent = self
light.Position = Vector3.new(0, 3, 0)

self.Position = Vector3.new(10, 0, 0)
local pos = light.Position
if pos then
    print(pos.X) -- prints 10
end

Size

Property
Size: vector

Size is the size of the entity along its local axes in units: (width, height, depth). On a user interface element, Size is a UIVector relative to its parent; read it typed through Box.

Default Vector3.new(0, 0, 0)

ProgressBar

Progress

Property
Progress: number

Progress is how full the progress bar is, from 0 to 1, drawn clamped to that range.

Default 0

ProgressColor

Property
ProgressColor: vector

ProgressColor is the color of a progress bar's fill.

Default Vector3.new(0.23, 0.51, 0.96)

ProgressTrackColor

Property
ProgressTrackColor: vector

ProgressTrackColor is the color of the track behind a progress bar's fill.

Default Vector3.new(1, 1, 1)

ProgressTrackTransparency

Property
ProgressTrackTransparency: number

ProgressTrackTransparency is the transparency of the track behind a progress bar's fill.

Default 0.94

Errors (1)
Error When
'ProgressTrackTransparency' is client-only; only client scripts may call it Called from a server script.

ProgressTransparency

Property
ProgressTransparency: number

ProgressTransparency is the transparency of a progress bar's fill.

Default 0

BusyColor

Property
BusyColor: vector

BusyColor is the color of the moving segment of a busy progress bar, one that shows work with no known end.

Default Vector3.new(0.23, 0.51, 0.96)

BusySpeed

Property
BusySpeed: number

BusySpeed is how many times a second a busy progress bar sweeps. Positive values sweep left to right, negative values sweep right to left, and 0 stops it.

Default 1

BusyTransparency

Property
BusyTransparency: number

BusyTransparency is the transparency of the moving segment of a busy progress bar.

Default 0

BusyWidth

Property
BusyWidth: number

BusyWidth is the width of the moving segment as a fraction of the bar's width, drawn clamped to 0 to 1.

Default 0.2

RopeJoint

ConnectedAnchor

Property
ConnectedAnchor: vector

ConnectedAnchor is where the rope attaches to ConnectedRigidbody, in units in that part's frame.

Default Vector3.new(0, 0, 0)

Errors (1)
Error When
'ConnectedAnchor' is client-only; only client scripts may write it Written from a server script.

ConnectedRigidbody

Property
ConnectedRigidbody: Entity?

ConnectedRigidbody is the part this part is tied to by a rope that keeps them at most Distance units apart. The rope forms only between parts with physics bodies in different assemblies, and setting nil or destroying either part removes it.

Default nil

Example

-- Server script in a ceiling part: hang a lamp on a 6-unit rope.
if self.Body then self.Body.Motion = "Static" end
local lamp = World.Spawn({ Shape = "Box", Body = {} })
lamp.Size = Vector3.new(1, 1, 1)
local pos = self.Position
if pos then
    lamp.Position = pos - Vector3.new(0, 6, 0)
end
lamp.Parent = World
lamp:Add(Component.RopeJoint)
local rope = lamp.RopeJoint
if rope then
    rope.Length = 6
    rope.Target = self
end

Distance

Property
Distance: number

Distance is the longest the rope stretches, in units. The parts can move closer. A running rope motor changes Distance as it reels.

Default 5

LowerTranslation

Property
LowerTranslation: number

LowerTranslation is the shortest Distance the rope motor reels in to. The motor stops there.

Default 0

MaximumMotorForce

Property
MaximumMotorForce: number

MaximumMotorForce is the most force in Newtons the rope motor pulls with.

Default 10000

MotorSpeed

Property
MotorSpeed: number

MotorSpeed is how fast the rope motor changes Distance, in units per second. A negative value reels in, a positive value reels out, and 0 stops the motor.

Default 0

Effects

  • The motor keeps Distance between LowerTranslation and UpperTranslation. A rope longer than UpperTranslation, which is 5 by default, jumps to that length when its motor starts.

Example

-- Server script in a crate that hangs on a rope: winch it up until the rope is 2 units long.
local rope = self.RopeJoint
if rope then
    rope.MinLength = 2
    rope.MotorSpeed = -1
end

RopeAnchor

Property
RopeAnchor: vector

RopeAnchor is where the rope attaches to this part, in units in its frame.

Default Vector3.new(0, 0, 0)

UpperTranslation

Property
UpperTranslation: number

UpperTranslation is the longest Distance the rope motor reels out to. The motor stops there.

Default 5

Rotation

PivotPoint

Property
PivotPoint: Vector2 | vector

PivotPoint is the point the element turns and scales about, as a fraction of its size: 0, 0 is the top-left corner and 1, 1 the bottom-right. It applies to Rotation and Scale and moves nothing by itself.

Default Vector2.new(0.5, 0.5)

Rotation

Property
Rotation: Rotation

Rotation turns the element and everything under it clockwise by this many degrees about its PivotPoint, after layout, so the box keeps its place in a list.

Default Rotation.Identity

Scale

Property
Scale: Vector2 | vector

Scale scales the element and everything under it by this X and Y factor about its PivotPoint, after layout, so siblings in a list do not move. A negative axis mirrors the element, and 0 on either axis hides it from drawing and the pointer.

Default Vector2.new(1, 1)

Errors (1)
Error When
'Scale' is client-only; only client scripts may call it Called from a server script.

ScrollFrame

CanvasPosition

Property
CanvasPosition: vector

CanvasPosition is the vertical scroll offset of a scrolling frame in pixels, as (0, Y). Writing it scrolls the frame, and a ScrollFollowing frame then stops following until the player scrolls back to the end.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local pane = World.Spawn({
    Box = {},
    Panel = {},
    ScrollFrame = { CanvasSize = UIVector.fromPoints(0, 1000) },
})
pane.Parent = screen

-- Back to the top after swapping pages.
local sf = pane.ScrollFrame
if sf then
    sf.CanvasPosition = Vector2.new(0, 0)
    print(sf.CanvasPosition.Y) -- prints 0
end

CanvasSize

Property
CanvasSize: UIVector

CanvasSize is the size of the area a scrolling frame scrolls over. When the area is wider or taller than the frame, the frame scrolls that way.

Default UIVector.Zero

ScrollBarThickness

Property
ScrollBarThickness: number

ScrollBarThickness is the width in pixels of the bar a scrolling frame draws while its canvas is taller than the frame. 0 draws none; the wheel and keys still scroll.

Default 4

ScrollFollowing

Property
ScrollFollowing: boolean

ScrollFollowing, when true, keeps the frame scrolled to the bottom as children are added or the scroll area grows.

Default false

Shape

Type

Property
Type: ShapeKind | string

Type is the basic shape of a part, used for drawing, raycasts and its default collider: "Box", "Sphere", "Cylinder" (along Y), "Cone" (pointing +Y) or "Wedge" (sloping along -Z), scaled by Size. A part with a Mesh draws the mesh instead. On an InputAction, Type is "Bool" or "Direction2D".

Default "Box"

Example

-- Server script in a part: drop a ball above it.
local ball = World.Spawn({ Shape = "Sphere" })
ball.Size = Vector3.new(2, 2, 2)
local pos = self.Position
if pos then
    ball.Position = pos + Vector3.new(0, 5, 0)
end
ball.Parent = World

RenderDisabled

Property
RenderDisabled: boolean

RenderDisabled, when true, hides the entity and everything under it in every camera and in shadows. Parts, decals, particles, SurfaceViews, Handles and the canvases of SurfaceCanvas and BillboardCanvas stop drawing, and lights go out. A BillboardCanvas whose Target is hidden stops drawing too, wherever the BillboardCanvas is. Physics, raycasts, sound and replication still work. Each descendant keeps its own value, so one that has RenderDisabled itself stays hidden when its ancestor shows again. A particle emitter that shows again starts over: its old particles are gone and its ParticleSpawnOnce burst fires a second time.

Setting Visible to false sets RenderDisabled, except on a UI element, SurfaceCanvas, BillboardCanvas or Handles, where it sets UIHidden instead.

Default false

Example

-- Server script in a part: hide the part and everything under it for 2 seconds.
self.Visible = false
task.wait(2)
self.Visible = true

ShadowOff

Property
ShadowOff: boolean

ShadowOff, when true, stops the entity from casting shadows. It still receives shadows.

Default false

Sound

Bus

Property
Bus: SoundBus

Bus is the mix bus the sound plays through: "Master", "Music", "SFX" or "UI". The sound plays at Volume * bus volume * Master volume, and on "Master" the Master volume counts once.

Default "Master"

ConeInnerAngle

Property
ConeInnerAngle: number

ConeInnerAngle is the full angle, in degrees, of the cone in which the sound plays at full volume. The cone points out of the entity's Front face (-Z) and turns with it. At 360 the sound is the same in every direction.

Default 360

ConeOuterAngle

Property
ConeOuterAngle: number

ConeOuterAngle is the full angle, in degrees, of the cone outside which the sound plays at ConeOuterGain. Between ConeInnerAngle and this angle, the volume drops linearly.

Default 360

ConeOuterGain

Property
ConeOuterGain: number

ConeOuterGain is the volume multiplier outside ConeOuterAngle. 0 silences the sound there.

Default 0

Looped

Property
Looped: boolean

Looped starts the clip again each time it ends, so Playing stays true. Setting it to false while the sound plays lets the current pass finish.

Default false

MaxPolyphony

Property
MaxPolyphony: number

MaxPolyphony is the most copies of this sound that play at once, such as overlapping footsteps. When Play would start one more, the oldest copy stops; at 1, Play restarts the sound.

Default 1

Pause

Method
Pause() -> ()

Pause pauses a playing sound and keeps its place in the clip.

Example

-- Server script in a part: pause the loop after 2 seconds.
local sound = self:Add(Component.Sound)
sound.SoundId = "144115188075855954"
sound.Looped = true
sound:Play()

task.wait(2)
sound:Pause()
print(sound.Playing, sound.Paused) -- prints false true

Paused

PropertyRead only
Paused: boolean

Paused is true while the sound is paused partway through. Pause sets it; Resume and Stop clear it.

Default false

Play

Method
Play() -> ()

Play starts the sound's clip from the beginning. The entity needs a Sound component.

Example

-- Server script in a part: play a sound when the script starts.
local sound = self:Add(Component.Sound)
sound.SoundId = "144115188075855954"
sound:Play()
print(sound.Playing) -- prints true

PlaybackSpeed

Property
PlaybackSpeed: number

PlaybackSpeed scales the speed and pitch of the sound: 2 plays one octave up, 0.5 one octave down. Values below 0.05 play at 0.05, so 0 does not pause the sound.

Default 1

Playing

PropertyRead only
Playing: boolean

Playing is true while the sound plays. On a client it is true while the entity has SoundAudible; the entity has SoundLoading while the clip loads and SoundFailed (Reason is "EmptyId", "InvalidId", "NotFound", "DecodeFailed", or "NoDevice") when playback fails. On the server it is true once the clip resolves and until a non-looping clip ends, Pause or Stop runs, or playback fails with SoundFailed.

Default false

Resume

Method
Resume() -> ()

Resume plays a paused sound from where it stopped.

Example

-- Server script in a part: pause the loop for 2 seconds, then go on.
local sound = self:Add(Component.Sound)
sound.SoundId = "144115188075855954"
sound.Looped = true
sound:Play()

sound:Pause()
task.wait(2)
sound:Resume()
print(sound.Playing) -- prints true

RollOffMaxDistance

Property
RollOffMaxDistance: number

RollOffMaxDistance is the distance, in units, past which the sound cannot be heard.

Default 10000

RollOffMinDistance

Property
RollOffMinDistance: number

RollOffMinDistance is the distance, in units, within which the sound plays at full volume.

Default 10

RollOffScale

Property
RollOffScale: number

RollOffScale is how fast the sound gets quieter past RollOffMinDistance: the volume is multiplied by min / (min + RollOffScale * (distance - min)), where min is RollOffMinDistance. At 0 the sound keeps full volume out to RollOffMaxDistance.

Default 1

SoundId

Property
SoundId: string

SoundId is the asset id of the audio clip, as a string of digits such as "144115188075855954". Write it in quotes: a Luau number cannot represent every digit, so an unquoted id names a different asset. In Studio, Copy ID on the sound field gives the id, and Import… imports an .ogg file.

Default "0"

Stop

Method
Stop() -> ()

Stop stops the sound and goes back to the start of the clip.

Example

-- Server script in a part: an alarm that rings for 2 seconds.
local sound = self:Add(Component.Sound)
sound.SoundId = "144115188075855954"
sound.Looped = true
sound:Play()

task.wait(2)
sound:Stop()
print(sound.Playing) -- prints false

Volume

Property
Volume: number

Volume is how loud the sound plays. 0 is silent and 1 is the recorded loudness.

Default 0.5

SwingTwistJoint

Anchor

Property
Anchor: vector

Anchor is the pivot of a swing-twist joint, in units in the parent part's frame. The joint links this part to its parent part and forms when this part has a dynamic body.

Default Vector3.new(0, 0, 0)

Example

-- Server script in a part: hang a lantern under it that swings up to 30 degrees.
if self.Body then self.Body.Motion = "Static" end
local lantern = World.Spawn({ Shape = "Box", Body = {} })
lantern.Size = Vector3.new(1, 2, 1)
local pos = self.Position
if pos then
    lantern.Position = pos - Vector3.new(0, 3, 0)
end
lantern.Parent = self
lantern:Add(Component.SwingTwistJoint)
local joint = lantern.SwingTwistJoint
if joint then
    joint.Anchor = Vector3.new(0, -2, 0)
    joint.TwistAxis = Vector3.new(0, -1, 0)
    joint.SwingLimit = 30
    joint.Target = self
end

FrictionTorque

Property
FrictionTorque: number

FrictionTorque is the torque in Newton-meters that keeps a settled swing-twist joint still. At 0 the joint turns freely.

Default 0

NormalCone

Property
NormalCone: number

NormalCone is a swing limit of the swing-twist joint in degrees. The joint swings within one cone whose half-angle is the larger of PlaneCone and NormalCone.

Default 90

PlaneAxis

Property
PlaneAxis: vector

PlaneAxis is the reference axis of the swing-twist joint's swing, in the parent part's frame. The default zero vector means (1, 0, 0).

Default Vector3.new(0, 0, 0)

PlaneCone

Property
PlaneCone: number

PlaneCone is a swing limit of the swing-twist joint in degrees. The joint swings within one cone whose half-angle is the larger of PlaneCone and NormalCone.

Default 90

TwistAxis

Property
TwistAxis: vector

TwistAxis is the axis TwistMin and TwistMax limit rotation around, in the parent part's frame. The default zero vector means (0, 1, 0).

Default Vector3.new(0, 0, 0)

TwistMax

Property
TwistMax: number

TwistMax is the upper rotation limit in degrees around TwistAxis, from the rest pose.

Default 45

TwistMin

Property
TwistMin: number

TwistMin is the lower rotation limit in degrees around TwistAxis, from the rest pose.

Default -45

Timer

TimeLeft

PropertyRead only
TimeLeft: number

TimeLeft is the number of seconds left on the countdown, or 0 when the timer is not running.

Default 0

Example

-- Server script in a part.
local timer = self:Add(Component.Timer)
timer:Start(10)

task.wait(4)
print(math.round(timer.TimeLeft)) -- prints 6

Timeout

EventRead only
Timeout: Signal<() -> ()>

Timeout fires each time the countdown reaches zero.

Example

-- Server script in a part: chime 3 times, 1 second apart.
self:Add(Component.Timer)

local count = 0
self:On(Component.Timer.Finished, function()
    count += 1
    print("chime", count)
    if count == 3 and self.Timer then
        self.Timer:Stop()
    end
end)

if self.Timer then
    self.Timer:Start(1)
end

TimerAutostart

Property
TimerAutostart: boolean

TimerAutostart starts the timer from WaitTime when the entity enters the world, then sets itself back to false.

Default false

TimerOneShot

Property
TimerOneShot: boolean

TimerOneShot stops the timer after one countdown. Without it, the timer starts over each time it fires.

Default false

TimerPaused

Property
TimerPaused: boolean

TimerPaused is true after Timer:Pause() and false after Timer:Resume(). On the server, setting it on an entity that has a timer does the same as calling those methods.

Default false

WaitTime

Property
WaitTime: number

WaitTime is how many seconds the timer counts down. Set it before you call Timer:Start(); a change takes effect on the next countdown.

Default 1

UICheckbox

BoxColor

Property
BoxColor: vector

BoxColor is the fill color of a checkbox's box.

Default Vector3.new(1, 1, 1)

BoxTransparency

Property
BoxTransparency: number

BoxTransparency is the transparency of a checkbox's box, from 0 (opaque) to 1 (invisible).

Default 0.94

CheckColor

Property
CheckColor: vector

CheckColor is the color of a checkbox's check mark.

Default Vector3.new(0.23, 0.51, 0.96)

CheckTransparency

Property
CheckTransparency: number

CheckTransparency is the transparency of the check mark, from 0 (opaque) to 1 (invisible).

Default 0

Checked

Property
Checked: boolean

Checked, when true, shows the checkbox's check mark. Clicking the checkbox flips it and fires Activated.

Default false

UIColorButton

SwatchColor

Property
SwatchColor: vector

SwatchColor is the color of a color swatch button.

Default Vector3.new(1, 1, 1)

SwatchPreview

Property
SwatchPreview: string

SwatchPreview is how a color swatch shows transparency: "Opaque" ignores it, "Checker" draws the color over a checkerboard, and "Half" draws the solid color on the left half and the checkerboard on the right.

Default "Checker"

SwatchTransparency

Property
SwatchTransparency: number

SwatchTransparency is the transparency of the color swatch.

Default 0

UIColorPicker

BarWidth

Property
BarWidth: number

BarWidth is the width in pixels of the hue strip along the right edge of a color picker.

Default 20

Brightness

Property
Brightness: number

Brightness is the value (the V of HSV) picked in a color picker, from 0 (black) to 1. Dragging up or down changes it.

Default 1

Hue

Property
Hue: number

Hue is the hue picked in a color picker, from 0 to 1 around the color wheel: red through green and blue back to red. Values outside 0 to 1 wrap.

Default 0

Saturation

Property
Saturation: number

Saturation is the saturation picked in a color picker, from 0 (gray) to 1 (full color). Dragging left or right changes it.

Default 1

UIDialog

Canceled

EventRead only
Canceled: Signal<() -> ()>

Canceled fires when the player cancels the dialog.

Example

-- Client script.
local ui = World.Spawn({ UIRoot = true })
ui.Parent = World.Viewport.Screen
local dialog = World.Spawn({ Box = {}, Panel = {}, UIDialog = { DialogTitle = "Quit" } })
dialog.Parent = ui
dialog:On(Component.UIDialog.Canceled, function()
    print("stay")
end)

CancelText

Property
CancelText: string

CancelText is the cancel button text; empty shows Cancel.

Default ""

Confirmed

EventRead only
Confirmed: Signal<() -> ()>

Confirmed fires when the player accepts the dialog.

Example

-- Client script.
local ui = World.Spawn({ UIRoot = true })
ui.Parent = World.Viewport.Screen
local dialog = World.Spawn({ Box = {}, Panel = {}, UIDialog = { DialogTitle = "Quit" } })
dialog.Parent = ui
dialog:On(Component.UIDialog.Confirmed, function()
    print("ok")
end)

ConfirmText

Property
ConfirmText: string

ConfirmText is the confirm button text; empty shows OK.

Default ""

DialogTitle

Property
DialogTitle: string

DialogTitle is the dialog's title.

Default ""

UIDock

DockPrefab

Property
DockPrefab: string

DockPrefab is the name of a prefab whose spawned UI root draws in this element's box instead of its own. It needs the UIDock component, which Entity:Add(Component.UIDock) adds. While the root exists, this element and its children do not draw. Writing "" returns both to their own places, and destroying either restores the other.

Default ""

UIFoldable

HeaderColor

Property
HeaderColor: vector

HeaderColor is the color of the header bar of a collapsible section.

Default Vector3.new(52/255, 56/255, 66/255)

Errors (1)
Error When
'HeaderColor' is client-only; only client scripts may call it Called from a server script.

HeaderHeight

Property
HeaderHeight: number

HeaderHeight is the height in pixels of a collapsible section's header bar. A collapsed section shrinks to this height; values below 0 count as 0.

Default 28

HeaderTransparency

Property
HeaderTransparency: number

HeaderTransparency is the transparency of a collapsible section's header bar.

Default 0

UIGraph

GraphOffset

Property
GraphOffset: Vector2 | vector

GraphOffset is how far a graph canvas is panned, in pixels.

Default Vector2.new(0, 0)

GraphZoom

Property
GraphZoom: number

GraphZoom is the zoom of a graph canvas.

Default 1

GraphZoomMax

Property
GraphZoomMax: number

GraphZoomMax is the highest zoom the mouse wheel reaches.

Default 2.0736

GraphZoomMin

Property
GraphZoomMin: number

GraphZoomMin is the lowest zoom the mouse wheel reaches.

Default 0.232568

GraphZoomStep

Property
GraphZoomStep: number

GraphZoomStep is the zoom factor of one mouse wheel notch.

Default 1.2

LinkFrom

Property
LinkFrom: Entity?

LinkFrom is the graph port where a wire starts.

Default nil

LinkRequested

EventRead only
LinkRequested: Signal<(from: Entity, to: Entity) -> ()>

LinkRequested fires on the client when the player drags between ports on a node graph.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local graph = World.Spawn({ Box = {}, Panel = {}, UIGraph = {} })
graph.Parent = screen
for x = 0, 1 do
    local node = World.Spawn({ Box = {}, Panel = {} })
    node.Parent = graph
    local box = node.Box
    if box then
        box.Position = UIVector.fromPoints(250 * x, 0)
    end
    local port = World.Spawn({ Box = {}, Panel = {}, UIGraphPort = {} })
    port.Parent = node
end
graph:On(Component.UIGraph.LinkRequested, function(from, to)
    local wire = World.Spawn({ Box = {}, Panel = {}, UIGraphLink = { LinkFrom = from, LinkTo = to } })
    wire.Parent = graph
end)

LinkTo

Property
LinkTo: Entity?

LinkTo is the graph port where a wire ends.

Default nil

PortColor

Property
PortColor: vector

PortColor is the wire color of a graph port.

Default Vector3.new(1, 1, 1)

PortTransparency

Property
PortTransparency: number

PortTransparency is the wire transparency of a graph port.

Default 0

WireCurvature

Property
WireCurvature: number

WireCurvature is how much graph wires curve, from 0 (straight) to 1.

Default 0.5

UIGridLayout

CellPadding

Property
CellPadding: number

CellPadding is the gap in pixels between neighboring cells of a grid, across and down.

Default 0

CellSize

Property
CellSize: Vector2 | vector

CellSize is the width and height in pixels of each cell of a grid. The grid's children take this size instead of their own.

Default Vector2.new(64, 64)

ColumnWidths

Property
ColumnWidths: {number}

ColumnWidths is the width in pixels of up to 16 columns of a grid or table. A non-zero entry replaces the shared cell width for that column; entries left out are 0.

Default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Columns

Property
Columns: number

Columns is the number of columns of a grid before items wrap to the next line, clamped between 1 and 8192 in layout.

Default 1

FillColumns

Property
FillColumns: boolean

FillColumns, when true, fits as many CellSize.X columns across a grid as its inner width has room for, ignoring Columns. FitColumns and ColumnWidths override it.

Default false

FitColumns

Property
FitColumns: boolean

FitColumns, when true, makes each grid column as wide as its widest cell.

Default false

FreezeRows

Property
FreezeRows: number

FreezeRows is the number of header lines that stay at the top of a scrolling table while the others scroll under them.

Default 1

GridLineColor

Property
GridLineColor: vector

GridLineColor is the color of the lines between table cells.

Default Vector3.new(1, 1, 1)

GridLineThickness

Property
GridLineThickness: number

GridLineThickness is the width in pixels of the lines between table cells; 0 draws none.

Default 1

GridLineTransparency

Property
GridLineTransparency: number

GridLineTransparency is the transparency of the lines between table cells, from 0 (opaque) to 1 (invisible).

Default 0.75

Margins

Property
Margins: Insets

Margins is the space in pixels inside the left, top, right and bottom edges of a list or grid. On a list it reads and writes MarginLeft, MarginTop, MarginRight and MarginBottom. On an element with neither layout, writing it adds a grid layout.

Default Insets.Zero

ResizableColumns

Property
ResizableColumns: boolean

ResizableColumns, when true, lets players drag the dividers between table columns to resize them.

Default false

UIHitSlop

HitSlopBottom

Property
HitSlopBottom: number

HitSlopBottom is how many points below the element's box the pointer still hits it, without changing drawing or layout; values below 0 count as 0. At script API 58, call e:Add(Component.UIHitSlop) before writing it.

Default 0

HitSlopLeft

Property
HitSlopLeft: number

HitSlopLeft is how many points left of the element's box the pointer still hits it; see HitSlopBottom for behavior.

Default 0

HitSlopRight

Property
HitSlopRight: number

HitSlopRight is how many points right of the element's box the pointer still hits it; see HitSlopBottom for behavior.

Default 0

HitSlopTop

Property
HitSlopTop: number

HitSlopTop is how many points above the element's box the pointer still hits it; see HitSlopBottom for behavior.

Default 0

UIIcon

IconAlign

Property
IconAlign: IconAlign

IconAlign is the side of the text the icon goes on: "Left", "Right", "Top" or "Bottom".

Default "Left"

IconGap

Property
IconGap: number

IconGap is the gap in pixels between the icon and the text.

Default 6

IconSize

Property
IconSize: number

IconSize is the width and height in pixels of the icon.

Default 20

UIItemList

SelectedIndex

Property
SelectedIndex: number

SelectedIndex is the 1-based index, in layout order, of the chosen child item, or 0 for none. The selection highlight draws behind that child. In a tab view it is the open tab.

Default 0

SelectionColor

Property
SelectionColor: vector

SelectionColor is the color of the highlight behind the selected list item.

Default Vector3.new(0.23, 0.51, 0.96)

SelectionTransparency

Property
SelectionTransparency: number

SelectionTransparency is the transparency of the highlight behind the selected list item, from 0 (opaque) to 1 (invisible).

Default 0.65

UIJoystick

StickCenter

Property
StickCenter: Vector2 | vector

StickCenter is the base of the thumbstick, from the element's center, as fractions of its width and height from -0.5 to 0.5. In "Dynamic" and "Following" modes the base moves to where the touch starts.

Default Vector2.new(0, 0)

StickDeadzone

Property
StickDeadzone: number

StickDeadzone is how far the thumb must move, as a fraction of StickRadius, before StickDirection leaves (0, 0).

Default 0

StickDirection

Property
StickDirection: Vector2 | vector

StickDirection is the direction from the thumbstick's base toward the thumb, X and Y from -1 to 1 with +Y down.

Default Vector2.new(0, 0)

StickMode

Property
StickMode: JoystickMode

StickMode is how the thumbstick base follows the touch: "Fixed" keeps it at StickCenter, "Dynamic" moves it to where the touch starts, and "Following" drags it along when the thumb goes past StickRadius.

Default "Fixed"

StickRadius

Property
StickRadius: number

StickRadius is how far, in pixels, the thumb can move from the center of the base.

Default 50

StickTip

Property
StickTip: Vector2 | vector

StickTip is where the thumb is relative to the base, in multiples of StickRadius. It returns to (0, 0) on release.

Default Vector2.new(0, 0)

UIListClipper

ItemCount

Property
ItemCount: number

ItemCount is the number of items in a long scrolling list, counting those off screen. The list reuses its children to show only the items in view.

Default 0

ItemHeight

Property
ItemHeight: number

ItemHeight is the height in pixels of every item of a long list. Below 1, children are not reused.

Default 30

ItemShown

EventRead only
ItemShown: Signal<(item: Entity, index: number) -> ()>

ItemShown fires on the client when an item scrolls into view, with the reused child and the item's 1-based index.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local list = World.Spawn({
    Box = {},
    Panel = {},
    ScrollFrame = {},
    UIListClipper = { ItemCount = 500 },
})
list.Parent = screen
for _ = 1, 11 do
    World.Spawn({ Box = {}, UITextSource = {} }).Parent = list
end

list:On(Component.UIListClipper.ItemShown, function(item: Entity, index: number)
    local label = item.UITextSource
    if label then
        label.Text = "Player " .. index
    end
end)

UIListLayout

Align

Property
Align: UIAlign

Align places a list's children across the direction it stacks them: "Start", "Center" or "End". It is horizontal when Axis is "Vertical" and vertical when Axis is "Horizontal".

Default "Start"

Axis

Property
Axis: UIDirection

Axis is the direction a list stacks its children: "Vertical" top to bottom, or "Horizontal" left to right.

Default "Vertical"

Justify

Property
Justify: UIAlign

Justify places the run of children along the stacking axis of a list: "Start", "Center" or "End". A "Grow" child fills the spare space, so Justify does nothing.

Default "Start"

MarginBottom

Property
MarginBottom: number

MarginBottom is the space in pixels inside the bottom edge of a list.

Default 0

MarginLeft

Property
MarginLeft: number

MarginLeft is the space in pixels inside the left edge of a list.

Default 0

MarginRight

Property
MarginRight: number

MarginRight is the space in pixels inside the right edge of a list.

Default 0

MarginTop

Property
MarginTop: number

MarginTop is the space in pixels inside the top edge of a list.

Default 0

Spacing

Property
Spacing: number

Spacing is the gap in pixels between a list's children along the direction it stacks them.

Default 0

UIListStripe

StripeColor

Property
StripeColor: vector

StripeColor is the color of every other line of a list or grid.

Default Vector3.new(1, 1, 1)

StripeTransparency

Property
StripeTransparency: number

StripeTransparency is the transparency of the stripes, from 0 (opaque) to 1 (invisible).

Default 0.94

UIMenu

HighlightColor

Property
HighlightColor: vector

HighlightColor is the background color of a menu item or dropdown entry under the pointer.

Default Vector3.new(0.23, 0.51, 0.96)

HighlightTransparency

Property
HighlightTransparency: number

HighlightTransparency is the transparency of the background of a menu item or dropdown entry under the pointer.

Default 0

Property
MenuCheck: boolean

MenuCheck, when true, makes a menu item keep room at its left edge for a check mark or radio dot.

Default false

Open

Property
Open: boolean

Open, when true, opens the dropdown's list. A click outside sets it to false.

Default false

PanelColor

Property
PanelColor: vector

PanelColor is the background color of a popup menu or dropdown list.

Default Vector3.new(0.12, 0.12, 0.14)

PanelTransparency

Property
PanelTransparency: number

PanelTransparency is the transparency of a popup menu or dropdown list's background.

Default 0.04

Radio

Property
Radio: boolean

Radio, when true, draws a round radio dot in place of a square check mark.

Default false

Shortcut

Property
Shortcut: string

Shortcut is text shown at the right of a menu item, such as "Ctrl+S". It does not bind the key.

Default ""

UIMultiSelect

MultiSelectColor

Property
MultiSelectColor: vector

MultiSelectColor is the color of the box a player drags to select several elements, and of the highlight behind each selected child.

Default Vector3.new(0.23, 0.51, 0.96)

MultiSelectTransparency

Property
MultiSelectTransparency: number

MultiSelectTransparency is the transparency of the multi-select drag box and the highlight behind each selected child.

Default 0.65

MultiSelected

Property
MultiSelected: boolean

MultiSelected, when true, makes the element part of the current multiple selection.

Default false

UINumberField

Number

Property
Number: number

Number is the value of a number field. Player input keeps it between NumberMin and NumberMax.

Default 0

Errors (1)
Error When
'Number' is client-only; only client scripts may write it Written from a server script.

NumberMax

Property
NumberMax: number

NumberMax is the highest value the player can enter.

Default 100

NumberMin

Property
NumberMin: number

NumberMin is the lowest value the player can enter.

Default 0

NumberStep

Property
NumberStep: number

NumberStep is how much a number field changes per drag step or arrow key. 0 lets the value change smoothly.

Default 1

UIPlot

PlotColor

Property
PlotColor: vector

PlotColor is the color of a plot's lines or bars.

Default Vector3.new(0.23, 0.51, 0.96)

PlotTransparency

Property
PlotTransparency: number

PlotTransparency is the transparency of a plot's lines or bars.

Default 0

PlotType

Property
PlotType: PlotKind

PlotType is how a plot draws its samples: "Lines" joins them with a line, and "Bars" draws a bar from zero to each sample.

Default "Lines"

SampleCount

Property
SampleCount: number

SampleCount is how many samples a plot keeps across its width, from 1 to 128. When the plot is full, each new sample pushes out the oldest. Client scripts append samples with UIPlot:Push(value).

Default 60

Example

-- Client script: plot the frame rate.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local plot = World.Spawn({ Box = {}, Panel = {}, UIPlot = {} })
plot.Parent = screen

function Update(dt: number)
    local view = plot.UIPlot
    if view and dt > 0 then
        view:Push(1 / dt)
    end
end

ScaleMax

Property
ScaleMax: number

ScaleMax is the value at the top edge of a plot. When ScaleMax is at or below ScaleMin, the plot fits its height to its samples.

Default 0

ScaleMin

Property
ScaleMin: number

ScaleMin is the value at the bottom edge of a plot. When ScaleMin is at or above ScaleMax, the plot fits its height to its samples.

Default 0

UIRadialFill

FillAmount

Property
FillAmount: number

FillAmount is how much of a round progress fill shows, from 0 (empty) to 1 (the full circle).

Default 1

FillMode

Property
FillMode: RadialFillDirection

FillMode is the way a round progress fill sweeps: "Clockwise", "Counterclockwise", or "BothWays" from the top center.

Default "Clockwise"

UIRadioButton

CircleColor

Property
CircleColor: vector

CircleColor is the color of a radio button's outer ring.

Default Vector3.new(1, 1, 1)

CircleTransparency

Property
CircleTransparency: number

CircleTransparency is the transparency of a radio button's outer ring, from 0 (opaque) to 1 (invisible).

Default 0.94

DotColor

Property
DotColor: vector

DotColor is the color of the dot of a selected radio button.

Default Vector3.new(0.23, 0.51, 0.96)

DotTransparency

Property
DotTransparency: number

DotTransparency is the transparency of a radio button's dot, from 0 (opaque) to 1 (invisible).

Default 0

RadioGroup

Property
RadioGroup: number

RadioGroup is the number that ties radio buttons together: selecting one unselects the others with the same number.

Default 0

Selected

Property
Selected: boolean

Selected, when true, makes this radio button the chosen option of its group.

Default false

UIScreenInsets

InsetEdge

Property
InsetEdge: string

InsetEdge is the screen edge this element keeps clear for elements that set ScreenInsets: "Top", "Right", "Bottom" or "Left". Only a visible element on the screen canvas reserves space.

Default "Top"

ScreenInsets

Property
ScreenInsets: string

ScreenInsets is which core UI screen edges the element stays clear of: "None", "CoreUISafeInsets", or "TopbarSafeInsets". "CoreUISafeInsets" lays the element out in the screen minus every edge reserved with InsetEdge, and "TopbarSafeInsets" minus only the top edge. It works only in the screen UI.

Default "None"

UIScrollBar

ScrollBarMax

Property
ScrollBarMax: number

ScrollBarMax is the end of a scroll bar's range, in units the script picks.

Default 100

ScrollBarMin

Property
ScrollBarMin: number

ScrollBarMin is the start of a scroll bar's range, in units the script picks.

Default 0

ScrollBarPage

Property
ScrollBarPage: number

ScrollBarPage is how much of a scroll bar's range shows at once, in the units of ScrollBarMin and ScrollBarMax.

Default 10

ScrollBarValue

Property
ScrollBarValue: number

ScrollBarValue is the scroll position. Dragging or clicking the bar changes it and keeps it between ScrollBarMin and ScrollBarMax - ScrollBarPage.

Default 0

UISeparator

LabelText

Property
LabelText: string

LabelText is text drawn centered in a separator line, splitting it in two. An empty string draws a plain line.

Default ""

LineColor

Property
LineColor: vector

LineColor is the color of a separator's line.

Default Vector3.new(0.43, 0.43, 0.5)

LineThickness

Property
LineThickness: number

LineThickness is the thickness in pixels of a separator's line.

Default 1

LineTransparency

Property
LineTransparency: number

LineTransparency is the transparency of a separator's line.

Default 0.5

UISlider

FillColor

Property
FillColor: vector

FillColor is the color of the slider track between its start and the thumb.

Default Vector3.new(0.23, 0.51, 0.96)

FillImage

Property
FillImage: string | DynamicImage

FillImage is the asset id of the image on the filled part of the slider track. "0" draws plain FillColor.

Default "0"

FillTransparency

Property
FillTransparency: number

FillTransparency is the transparency of the filled part of the slider track, from 0 (opaque) to 1 (invisible).

Default 0

HighValue

Property
HighValue: number

HighValue is the step of the upper thumb of a two-thumb range slider, from 0 to Steps - 1. Dragging never puts it below the lower thumb.

Default 0

MaxValue

Property
MaxValue: number

MaxValue is the highest value of a slider.

Default 1

MinValue

Property
MinValue: number

MinValue is the lowest value of a slider.

Default 0

SliderFormat

Property
SliderFormat: string

SliderFormat is a format string for the slider's value label, with string formatting specifiers for the number. An empty string shows the plain number.

Default ""

SliderValue

Property
SliderValue: number

SliderValue is the current value of a slider. Dragging moves it between MinValue and MaxValue and fires Activated.

Default 0

Steps

Property
Steps: number

Steps is the number of stops along a slider's track, from 2 to 255.

Default 2

ThumbColor

Property
ThumbColor: vector

ThumbColor is the color of the slider's thumb.

Default Vector3.new(0.23, 0.51, 0.96)

ThumbCornerRadius

Property
ThumbCornerRadius: number

ThumbCornerRadius is the corner radius in pixels, 0 to 1000, of the slider's thumb. 0 draws a round thumb.

Default 0

ThumbImage

Property
ThumbImage: string | DynamicImage

ThumbImage is the asset id of the image on the slider's thumb. "0" draws a plain thumb in ThumbColor.

Default "0"

ThumbSize

Property
ThumbSize: number

ThumbSize is the diameter of a round slider thumb or the side of a square one, in pixels from 0 to 1000.

Default 14

ThumbTransparency

Property
ThumbTransparency: number

ThumbTransparency is the transparency of the slider's thumb, from 0 (opaque) to 1 (invisible).

Default 0

TickColor

Property
TickColor: vector

TickColor is the color of the tick marks along the slider's track.

Default Vector3.new(1, 1, 1)

TickLength

Property
TickLength: number

TickLength is the length in pixels, 0 to 1000, of the tick marks across the slider's track; 0 draws none.

Default 8

TickTransparency

Property
TickTransparency: number

TickTransparency is the transparency of the tick marks, from 0 (opaque) to 1 (invisible).

Default 0.75

TrackAxis

Property
TrackAxis: UIDirection

TrackAxis is the way the slider runs: "Horizontal" left to right, or "Vertical" up and down.

Default "Horizontal"

TrackColor

Property
TrackColor: vector

TrackColor is the color of the unfilled part of the slider's track.

Default Vector3.new(1, 1, 1)

TrackImage

Property
TrackImage: string | DynamicImage

TrackImage is the asset id of the image on the unfilled part of the slider's track. "0" draws a plain track in TrackColor.

Default "0"

TrackThickness

Property
TrackThickness: number

TrackThickness is the thickness in pixels, 0 to 1000, of the slider's track.

Default 6

TrackTransparency

Property
TrackTransparency: number

TrackTransparency is the transparency of the unfilled track, from 0 (opaque) to 1 (invisible).

Default 0.94

Value

Property
Value: number

Value is the step the slider's thumb is on, from 0 to Steps - 1. Dragging the thumb changes it and fires Activated.

Default 0

UISurface

SurfaceCanvasSizeX

Property
SurfaceCanvasSizeX: number

SurfaceCanvasSizeX is the width in pixels of the 2D canvas drawn on a face of the parent part.

Default 800

Errors (1)
Error When
'SurfaceCanvasSizeX' is runtime state; only a server script writes it Written from a client script.

SurfaceCanvasSizeY

Property
SurfaceCanvasSizeY: number

SurfaceCanvasSizeY is the height in pixels of the 2D canvas drawn on a face of the parent part.

Default 600

SurfaceFace

Property
SurfaceFace: Face

SurfaceFace is the face of the parent part the surface UI draws on: "Right", "Top", "Back", "Left", "Bottom" or "Front".

Default "Front"

SurfaceLightInfluence

Property
SurfaceLightInfluence: number

SurfaceLightInfluence is how much scene lighting shades the surface canvas, from 0 (always full brightness) to 255 (lit like the scene).

Default 255

SurfaceMaxDistance

Property
SurfaceMaxDistance: number

SurfaceMaxDistance is how far, in world units, the local character can be from the surface and still use its controls; 0 allows any distance.

Default 0

SurfacePixelsPerUnit

Property
SurfacePixelsPerUnit: number

SurfacePixelsPerUnit is how many canvas pixels cover one world unit of the face. When positive it sets the canvas size; 0 uses SurfaceCanvasSizeX and SurfaceCanvasSizeY.

Default 50

UISurfaceAlwaysOnTop

Property
UISurfaceAlwaysOnTop: boolean

UISurfaceAlwaysOnTop, when true, draws the surface UI in front of everything in the 3D scene.

Default false

UITableHeader

HeaderCell

Property
HeaderCell: boolean

HeaderCell, when true, makes the grid cell look and work as a clickable column header.

Default false

SortColumn

Property
SortColumn: number

SortColumn is the column, counted from 0, that a table sorts by, or -1 for none. Clicking a sortable column header changes SortColumn; a column that does not exist turns sorting off.

Default -1

SortDescending

Property
SortDescending: boolean

SortDescending, when true, sorts the table from highest to lowest.

Default false

UITabs

SelectedTabColor

Property
SelectedTabColor: vector

SelectedTabColor is the color of the open tab's button.

Default Vector3.new(59/255, 130/255, 245/255)

SelectedTabTransparency

Property
SelectedTabTransparency: number

SelectedTabTransparency is the transparency of the open tab's button.

Default 0

TabColor

Property
TabColor: vector

TabColor is the color of the buttons of tabs that are not open.

Default Vector3.new(31/255, 31/255, 36/255)

TabTransparency

Property
TabTransparency: number

TabTransparency is the transparency of the buttons of tabs that are not open.

Default 0

UITextInput

CursorColor

Property
CursorColor: vector

CursorColor is the color of the blinking caret of a text box being typed in.

Default Vector3.new(1, 1, 1)

CursorPosition

Property
CursorPosition: number

CursorPosition is the byte position of the caret in a focused text box, counted from 1 as string.sub counts, or nil while the box has no focus. Only client scripts can read or write it. Writing it moves the caret; without focus, a write does nothing.

CursorTransparency

Property
CursorTransparency: number

CursorTransparency is the transparency of the caret, from 0 (opaque) to 1 (invisible).

Default 0

Focused

EventRead only
Focused: Signal<() -> ()>

Focused fires on the client when this text box gains keyboard focus from a click, a tap or UITextInput:Focus().

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local box = World.Spawn({ Box = {}, Panel = {}, UITextInput = {}, Button = true })
box.Parent = screen
box:On(Component.UITextInput.Focused, function()
    local tb = box.UITextInput
    if tb then
        tb.PlaceholderText = ""
    end
end)

FocusLost

EventRead only
FocusLost: Signal<(enterPressed: boolean) -> ()>

FocusLost fires on the client when this text box loses keyboard focus. The callback receives true when the player pressed the return key.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local box = World.Spawn({ Box = {}, Panel = {}, UITextInput = {}, Button = true })
box.Parent = screen
box:On(Component.UITextInput.FocusLost, function(submitted: boolean)
    print("submitted", submitted)
end)

MaxLength

Property
MaxLength: number

MaxLength is the most bytes the player can type or paste into the text box, up to 65535; 0 sets no limit. A script that writes Text is not cut to the limit.

Default 0

Password

Property
Password: boolean

Password, when true, shows asterisks in the text box in place of what the player types. Text keeps the real characters.

Default false

PlaceholderColor

Property
PlaceholderColor: vector

PlaceholderColor is the color of a text box's PlaceholderText. Until it is written, the placeholder draws in a dim gray.

Default Vector3.new(0.7, 0.7, 0.7)

PlaceholderText

Property
PlaceholderText: string

PlaceholderText is the hint a text box shows while its Text is empty and it is not being typed in.

Default ""

ReleaseFocus

MethodClient only
ReleaseFocus(submitted: boolean?) -> ()

ReleaseFocus takes keyboard focus away from this text box as a click elsewhere does and fires FocusLost with the boolean passed, or false when omitted. Only client scripts can call it.

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local box = World.Spawn({ Box = {}, Panel = {}, UITextInput = {}, Button = true })
box.Parent = screen
box:On(Component.UITextInput.FocusLost, function(submitted: boolean)
    print(submitted)
end)
local tb = box.UITextInput
if tb then
    tb:Focus()
    tb:ReleaseFocus(true)
end
Property
SearchBox: boolean

SearchBox, when true, shows a clear button at the right end of the text box while it has text. Clicking it sets Text to "".

Default false

SelectionStart

Property
SelectionStart: number

SelectionStart is the byte position, counted from 1, of the end of the selection opposite the caret in a focused text box, or nil when nothing is selected or the box has no focus. Only client scripts can read or write it. Writing it selects the text between it and the caret, and writing nil clears the selection.

UITextStyle

Bold

Property
Bold: boolean

Bold reads true when FontWeight is 600 or more. Writing true sets FontWeight to 700 and false sets it to 400.

Default false

FontFamily

Property
FontFamily: LabelFont

FontFamily is the typeface of the text: "Arimo", "Montserrat", "Fredoka", "Nunito", "Roboto", "RobotoMono", "Oswald", "Merriweather", "Bangers", "LuckiestGuy", "PressStart2P", "PermanentMarker" or "Creepster". Spaces and case do not count, so "Press Start 2P" works. A character the family lacks draws in Arimo, then in the emoji font.

Default "Arimo"

FontWeight

Property
FontWeight: number

FontWeight is the weight of the text, from 100 (thin) through 400 (regular) and 700 (bold) to 900 (black). Values clamp between 1 and 1000.

Default 400

Italic

Property
Italic: boolean

Italic, when true, slants the text by 14 degrees.

Default false

LineHeight

Property
LineHeight: number

LineHeight is the spacing of text lines as a multiple of the font's line spacing, from 1 to 3.

Default 1

NoTranslate

Property
NoTranslate: boolean

NoTranslate, when true, shows the element's Text as written, never translated to the player's language.

Default false

RichText

Property
RichText: boolean

RichText, when true, draws Text as markup with lowercase <b> (weight 700), <i>, <font color weight>, <br /> and the &lt; &gt; &quot; &apos; &amp; escapes. Markup that does not parse draws as written, and a text box ignores RichText.

Default false

Example

-- Client script.
local screen = World.Spawn({ UIRoot = true })
screen.Parent = World.Viewport.Screen
local label = World.Spawn({
    Box = {},
    UIRichText = true,
    UITextSource = {
        Text = 'Score: 10 <font color="#ff4040">-2</font>',
    },
})
label.Parent = screen

Text

Property
Text: string

Text is the text of a label, text box or button. With a "Fit" size mode, the element sizes to it.

Default ""

TextColor

Property
TextColor: vector

TextColor is the color of the text.

Default Vector3.new(1, 1, 1)

TextSize

Property
TextSize: number

TextSize is the height of the text in pixels, from 1 to 512.

Default 14

TextStrokeColor

Property
TextStrokeColor: vector

TextStrokeColor is the color of the outline around the text.

Default Vector3.new(0, 0, 0)

TextStrokeScale

Property
TextStrokeScale: number

TextStrokeScale, from 0 to 0.1, adds TextStrokeScale * TextSize pixels to TextStrokeWidth, so the outline keeps its ratio to the text at any size. Larger values make outlines overlap neighboring letters.

Default 0

TextStrokeTransparency

Property
TextStrokeTransparency: number

TextStrokeTransparency is the transparency of the text outline, from 0 (opaque) to 1 (invisible).

Default 1

TextStrokeWidth

Property
TextStrokeWidth: number

TextStrokeWidth is how many pixels, from 0 to 64, the text outline grows outward, clamped to about TextSize / 6. With TextStrokeScale also 0, there is no outline.

Default 0

TextTransparency

Property
TextTransparency: number

TextTransparency is the transparency of the text, from 0 (opaque) to 1 (invisible).

Default 0

TextTruncate

Property
TextTruncate: string

TextTruncate is how a line of text that runs past the element's width ends. "AtEnd" ends the line at the last letter that fits and draws an ellipsis; "None" lets it run past. A text box and wrapped text are not affected.

Default "None"

TextWrapped

Property
TextWrapped: boolean

TextWrapped, when true, breaks lines at spaces to fit the element's width. When false, a long line is cut off or runs past the element.

Default false

TextXAlignment

Property
TextXAlignment: TextAlignX

TextXAlignment aligns the text horizontally in the element: "Left", "Center" or "Right".

Default "Left"

TextYAlignment

Property
TextYAlignment: TextAlignY

TextYAlignment aligns the text vertically in the element: "Top", "Center" or "Bottom".

Default "Top"

UIToggle

KnobColor

Property
KnobColor: vector

KnobColor is the color of a toggle switch's knob.

Default Vector3.new(1, 1, 1)

KnobImage

Property
KnobImage: string | DynamicImage

KnobImage is the asset id of the image on a toggle switch's knob. "0" draws a plain knob in KnobColor.

Default "0"

KnobInset

Property
KnobInset: number

KnobInset is the gap in pixels between a toggle switch's track and knob.

Default 2

KnobTransparency

Property
KnobTransparency: number

KnobTransparency is the transparency of a toggle switch's knob, from 0 (opaque) to 1 (invisible).

Default 0

Mixed

Property
Mixed: boolean

Mixed, when true, places a toggle switch's knob in the middle. Clicking clears Mixed and flips On.

Default false

OffColor

Property
OffColor: vector

OffColor is the color of a toggle switch's track while On is false.

Default Vector3.new(1, 1, 1)

OffImage

Property
OffImage: string | DynamicImage

OffImage is the asset id of the image on a toggle switch's track while it is off. "0" draws a plain track in OffColor.

Default "0"

OffTransparency

Property
OffTransparency: number

OffTransparency is the transparency of a toggle switch's track while it is off, from 0 (opaque) to 1 (invisible).

Default 0.94

On

Property
On: boolean

On is whether a toggle switch or UIToggleButton is on. Clicking flips it and fires Activated.

Default false

OnColor

Property
OnColor: vector

OnColor is the color of a toggle switch's track while On is true.

Default Vector3.new(0.23, 0.51, 0.96)

OnImage

Property
OnImage: string | DynamicImage

OnImage is the asset id of the image on a toggle switch's track while it is on. "0" draws a plain track in OnColor.

Default "0"

OnTransparency

Property
OnTransparency: number

OnTransparency is the transparency of a toggle switch's track while it is on, from 0 (opaque) to 1 (invisible).

Default 0

SwitchWidth

Property
SwitchWidth: number

SwitchWidth is the width in pixels of a toggle switch's track; 0 makes it twice the element's height.

Default 0

TogglePrefab

Property
TogglePrefab: string

TogglePrefab is the name of a prefab whose spawned UI root this button shows or hides when clicked. The engine sets the button's On while that root is visible.

Default ""

ToggleTarget

PropertyClient onlyRead only
ToggleTarget: Entity?

ToggleTarget is the UIRoot that TogglePrefab names, or nil while none exists.

Default nil

UIToggleButton

Property
UIToggleButton: boolean

UIToggleButton, when true, makes the button stay pressed after a click and pop back up on the next click.

Default false

UITreeView

BranchColor

Property
BranchColor: vector

BranchColor is the color of the lines that join parent and child nodes in a tree view.

Default Vector3.new(150/255, 155/255, 168/255)

BranchTransparency

Property
BranchTransparency: number

BranchTransparency is the transparency of the tree view lines.

Default 0

Folded

Property
Folded: boolean

Folded, when true, collapses the tree node and hides everything under it.

Default false

Indent

Property
Indent: number

Indent is how far, in pixels, each level of a tree view moves its children to the right.

Default 16

UIVectorField

VectorCount

Property
VectorCount: number

VectorCount is how many fields a vector input shows: 2 (X, Y) or 3 (X, Y, Z).

Default 3

VectorMax

Property
VectorMax: number

VectorMax is the highest value a vector input's fields take, ignored at or below VectorMin.

Default 0

VectorMin

Property
VectorMin: number

VectorMin is the lowest value a vector input's fields take, ignored at or above VectorMax.

Default 0

VectorSpeed

Property
VectorSpeed: number

VectorSpeed is how much a vector input field changes per pixel the pointer drags sideways.

Default 0.1

Errors (1)
Error When
'VectorSpeed' is client-only; only client scripts may write it Written from a server script.

VectorValue

Property
VectorValue: vector

VectorValue is the vector a vector input shows and edits. Dragging or typing in a field changes it and fires Activated.

Default Vector3.new(0, 0, 0)

UIWindow

GripSize

Property
GripSize: number

GripSize is the size in pixels of the square resize handle in a window's corner.

Default 16

TitleHeight

Property
TitleHeight: number

TitleHeight is the height in pixels of a window's title bar, which the player drags to move the window.

Default 32

Floating

Property
Floating: boolean

Floating, when true, takes the element out of its parent's list or grid layout. Its Position and AnchorPoint place it in the parent's box.

Default false

UvTransform

Angle

Property
Angle: number

Angle turns the texture, in degrees, around the UV center (0.5, 0.5).

Default 0

Offset

Property
Offset: vector

Offset slides the texture by X and Y texture widths along U and V; Z is ignored.

Default Vector3.new(0, 0, 0)

Example

-- Server script in a conveyor part with a textured material.
self:Add(Component.UvTransform)
local SPEED = 0.5 -- widths per second

function Update(dt: number)
    local uv = self.UvTransform
    if uv then
        local x = (uv.Offset.X + SPEED * dt) % 1
        uv.Offset = Vector2.new(x, 0)
    end
end

Tiling

Property
Tiling: vector

Tiling scales the U and V texture coordinates by X and Y; Z is ignored. Values above 1 repeat the texture, values between 0 and 1 stretch it, and negative values mirror it. Triplanar and stud materials, and the clothing layer that Color describes, ignore UvTransform.

Default Vector3.new(1, 1, 0)

Velocity

Velocity

Property
Velocity: vector

Velocity is the linear velocity of the body in units per second, in world space. On a member of a welded assembly, Velocity is the velocity of that member's point.

Write a character's Velocity from a server script; a client write does not move it. A write on a body part such as the Left Leg that Component.Collider.Touched passes does nothing, so write Velocity on its Character.

Default Vector3.new(0, 0, 0)

Effects

  • On a static body, Velocity moves the surface while the part stays put, as on a conveyor belt. Parts and characters on it ride along.
  • On a static part with a water material, Velocity is the current that floating parts and swimming characters drift with.

Example

-- Server script in a jump pad part.
local launch = Vector3.new(0, 60, 0)

self:On(Component.Collider.Touched, function(hit: Entity)
    if hit.Character then
        hit.Velocity = launch
    end
end)

Weld

BreakForce

Property
BreakForce: number

BreakForce is the reaction force in Newtons that breaks the part's weld or assembly link. When a physics step pulls harder, the part and the members below it fly off as one body. 0 never breaks, and a weld to a character never breaks.

Default 0

BreakTorque

Property
BreakTorque: number

BreakTorque is the reaction torque in Newton-meters that breaks the part's weld or assembly link, as BreakForce does for force.

Default 0

Other

Property
Other: Entity?

Other is the part this part is welded to. Setting it makes the two parts one body in the pose they have at that moment; setting nil separates them again. The target must be another part with a physics body outside this part's assembly, or the weld does not form.

Set Other from a server script; on a client the weld does not hold. Place a part before welding it to a character, because a part welded to a character ignores later Position writes.

Default nil

Example

-- Server script in a part: weld a handle on top of it.
local handle = World.Spawn({ Shape = "Box", Body = {} })
local pos = self.Position
if pos then
    handle.Position = pos + Vector3.new(0, 2, 0)
end
handle.Parent = World
handle:Add(Component.Weld)
local weld = handle.Weld
if weld then
    weld.Target = self
end

WheelJoint

Axle

Property
Axle: vector

Axle is the direction the wheel spins around, in the wheel's own frame. The default spins a Cylinder wheel the way it rolls.

Default Vector3.new(0, 1, 0)

Chassis

Property
Chassis: Entity?

Chassis is the body this wheel hangs from. The wheel spins around Axle and moves up and down Travel units on a spring; it does not collide with its chassis. The joint forms only between parts with physics bodies in different assemblies, and setting nil or destroying either part removes it.

Default nil

Example

-- Server script in a level car body part: put a wheel under each corner and drive.
local corners = {
    Vector3.new(-3.5, -1, 4), Vector3.new(3.5, -1, 4),
    Vector3.new(-3.5, -1, -4), Vector3.new(3.5, -1, -4),
}
for _, corner in corners do
    local wheel = World.Spawn({ Shape = "Cylinder", Body = {} })
    wheel.Size = Vector3.new(2.4, 1, 2.4)
    local pos = self.Position
    if pos then
        wheel.Position = pos + corner
    end
    wheel.Rotation = Rotation.fromEuler(Vector3.new(0, 0, 90))
    wheel.Parent = World
    wheel:Add(Component.WheelJoint)
    local joint = wheel.WheelJoint
    if joint then
        joint.Target = self
        joint.MaxMotorTorque = 2000
        joint.MotorSpeed = 570
    end
end

CorneringStiffness

Property
CorneringStiffness: number

CorneringStiffness (TirePatchConfig) is the sideways grip a tire gains per radian of slip angle, as a multiple of its load. A stiffer tire reaches PeakFriction, and starts to slide, at a smaller angle.

Default 17.9

DriveTorque

Property
DriveTorque: number

DriveTorque is the most torque the wheel's motor applies to reach SpinSpeed. At 0 the wheel rolls freely.

Default 0

LongitudinalStiffness

Property
LongitudinalStiffness: number

LongitudinalStiffness (TirePatchConfig) is the forward grip a tire gains per unit of slip ratio, as a multiple of its load. A stiffer tire reaches PeakFriction, and starts to spin or lock, at less slip.

Default 19

MaxSteerTorque

Property
MaxSteerTorque: number

MaxSteerTorque is the most torque the steering spring applies to turn a Steers wheel. 0 does not limit the spring.

Default 0

Mount

PropertyRead only
Mount: vector

Mount is where the wheel rests on its Chassis, in the chassis's frame. The engine records it when the wheel joint first forms, and the suspension springs back to it. Setting Chassis or Axle records it again.

Default Vector3.new(0, 0, 0)

PeakFriction

Property
PeakFriction: number

PeakFriction (TirePatchConfig) is the friction of a tire at its best slip. It mixes with the ground's friction like any part's friction.

Default 1

RollingResistance

Property
RollingResistance: number

RollingResistance (TirePatchConfig) is the torque against a tire's rolling, as a fraction of its load.

Default 0.015

SpinSpeed

Property
SpinSpeed: number

SpinSpeed is the spin in degrees per second that the wheel's motor drives the wheel toward, with up to DriveTorque. At 0 the motor brakes. The engine limits the spin to 43,200 degrees per second.

Default 0

SpringDamping

Property
SpringDamping: number

SpringDamping is how fast a wheel's suspension stops bouncing. At 1 the wheel settles without bouncing, and at 0 it bounces forever.

Default 0.7

SpringFrequency

Property
SpringFrequency: number

SpringFrequency is the stiffness of a wheel's suspension in bounces per second, whatever the masses. At 0 the wheel slides freely within Travel.

Default 8

SteerLimit

Property
SteerLimit: number

SteerLimit is how far in degrees a Steers wheel may turn either way. At 0 the wheel stays straight.

Default 0

SteerTarget

Property
SteerTarget: number

SteerTarget is the angle in degrees the steering spring turns a Steers wheel toward, within SteerLimit.

Default 0

Steers

Property
Steers: boolean

Steers lets a wheel turn about the chassis's up direction toward SteerTarget.

Default false

Example

-- Server script in a front wheel: let it steer up to 30 degrees and turn it 20.
local joint = self.WheelJoint
if joint then
    joint.Steers = true
    joint.SteerLimit = 30
    joint.SteerAngle = 20
end

SuspensionDamping

Property
SuspensionDamping: number

SuspensionDamping (RaycastSuspension) is the damping against suspension speed, as a multiple of the parent part's mass. At 0 the parent part keeps bouncing.

Default 0.83

SuspensionDirection

Property
SuspensionDirection: vector

SuspensionDirection (RaycastSuspension) is the direction the wheel drops from SuspensionHardpoint, in the parent part's frame. A zero vector turns the suspension off.

Default Vector3.new(0, -1, 0)

SuspensionHardpoint

Property
SuspensionHardpoint: vector

SuspensionHardpoint (RaycastSuspension) is where the raycast suspension of a wheel part mounts on the wheel's parent part, in units in the parent's frame. A ray from this point finds the ground, and the spring pushes the parent upward at this point.

Default Vector3.new(0, 0, 0)

SuspensionMaxLength

Property
SuspensionMaxLength: number

SuspensionMaxLength (RaycastSuspension) is the farthest the wheel hangs from SuspensionHardpoint, in units. Past it the wheel leaves the ground.

Default 7

SuspensionMinLength

Property
SuspensionMinLength: number

SuspensionMinLength (RaycastSuspension) is the shortest the suspension compresses to, in units. The spring pushes no harder past it.

Default -1

SuspensionRestLength

Property
SuspensionRestLength: number

SuspensionRestLength (RaycastSuspension) is the distance in units from SuspensionHardpoint where the spring pushes with no force.

Default 3

SuspensionStiffness

Property
SuspensionStiffness: number

SuspensionStiffness (RaycastSuspension) is the spring force per unit of compression, as a multiple of the parent part's mass.

Default 5.88

SuspensionWheelRadius

Property
SuspensionWheelRadius: number

SuspensionWheelRadius (RaycastSuspension) is the radius of the wheel in units for the raycast suspension.

Default 10

Travel

Property
Travel: number

Travel is how far in units a WheelJoint moves up and down from its Mount. 0 is a rigid axle.

Default 0.5

WheelRadius

Property
WheelRadius: number

WheelRadius (TirePatchConfig) is the radius of a tire in units for the tire model. The tire rolls without slip when its spin times WheelRadius equals its ground speed.

Default 1