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
ChildAdded¶
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
ChildRemoved¶
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
Clone¶
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
selfset 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.Avatarstays 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¶
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
Emit¶
Emit fires the named custom signal on this entity, passing any extra arguments to connected handlers.
Example
GetSignal¶
GetSignal returns the named custom Signal on this entity, creating it on first use. Fire it with Emit.
Example
InputMove¶
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¶
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¶
IsAlive returns true until the entity is destroyed, then false.
Example
IsDescendantOf¶
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
Errors (1)
| Error | When |
|---|---|
'IsDescendantOf' is client-only; only client scripts may write it |
Written from a server script. |
Name¶
Name is the name of this entity in the scene tree, at most 65535 bytes.
Default ""
Parent¶
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
Worldto move an entity to the top.
Example
ViewSource¶
ViewSource is the camera whose view World.Viewport.Screen shows, or nil for none.
Default nil
AeroSurface¶
Area¶
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
CenterOfPressure¶
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¶
InducedDragFactor is the drag coefficient a wing adds per squared lift coefficient: C_D = ZeroLiftDrag + InducedDragFactor * C_L ^ 2.
Default 0.3183
LiftSlope¶
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¶
StallAngle is the angle of attack in degrees past which a wing's lift coefficient stops growing.
Default 15
ZeroLiftDrag¶
ZeroLiftDrag is a wing's drag coefficient when it makes no lift.
Default 0.02
Animator¶
ActiveAnimation¶
ActiveAnimation returns the name of the clip the character plays, or nil when it plays none. At API 58 read Animator.ActiveClip.
Example
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¶
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
AutoLocomotion¶
AutoLocomotion plays the character's walk, idle and jump animations from how it moves. It needs CharacterAnimation.
Default false
CharacterAnimation¶
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¶
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
PlayAnimation¶
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
RootMotion¶
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¶
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
Errors (1)
| Error | When |
|---|---|
'StopAnimation' is runtime state; only a server script writes it |
Written from a client script. |
Atmosphere¶
BackgroundColor¶
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¶
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¶
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¶
PanoramaEnergyMultiplier is the brightness of a panorama sky, from 0 to 128, multiplied by BackgroundEnergyMultiplier.
Default 1
PanoramaRotation¶
PanoramaRotation turns a panorama sky around the horizon, in degrees from 0 to 360.
Default 0
SkyboxBk¶
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¶
SkyboxDn is the asset id of the bottom face (-Y) of a six-sided sky.
Default "0"
SkyboxEnergyMultiplier¶
SkyboxEnergyMultiplier is the brightness of a six-sided sky, from 0 to 128, multiplied by BackgroundEnergyMultiplier.
Default 1
SkyboxFt¶
SkyboxFt is the asset id of the front face (-Z) of a six-sided sky.
Default "0"
SkyboxLf¶
SkyboxLf is the asset id of the left face (-X) of a six-sided sky.
Default "0"
SkyboxRotation¶
SkyboxRotation turns a six-sided sky around the horizon, in degrees from 0 to 360.
Default 0
SkyboxRt¶
SkyboxRt is the asset id of the right face (+X) of a six-sided sky.
Default "0"
SkyboxUp¶
SkyboxUp is the asset id of the top face (+Y) of a six-sided sky.
Default "0"
Billboard¶
BillboardColor¶
BillboardColor is the text color of the camera-facing 3D billboard label.
Default Vector3.new(1, 1, 1)
BillboardMaxDistance¶
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¶
BillboardOffset is the center of the billboard text, in world units from the entity's position.
Default Vector3.new(0, 0, 0)
BillboardOnTop¶
BillboardOnTop, when true, draws the billboard text in front of everything.
Default false
BillboardScreenSize¶
BillboardScreenSize is the part of the text height in screen points, the same at any distance. It adds to BillboardWorldSize.
Default 20
BillboardText¶
BillboardText is the text of the camera-facing 3D billboard label. An empty string hides the label.
Default ""
BillboardViewerDistance¶
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¶
BillboardWorldSize is the part of the text height in world units, which looks smaller farther away. It adds to BillboardScreenSize.
Default 0
Border¶
BorderColor¶
BorderColor is the color of the border around the element.
Default Vector3.new(0, 0, 0)
BorderFocusOnly¶
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¶
BorderSizePixel is the width in pixels of the border, drawn inside the element's edges; 0 draws none.
Default 1
BorderTransparency¶
BorderTransparency is the transparency of the border, from 0 (opaque) to 1 (invisible).
Default 0
Box¶
AnchorPoint¶
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¶
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¶
ClipsDescendants, when true, cuts off the elements under this one at its edges.
Default false
Disabled¶
Disabled, when true, dims the element and stops it from taking the pointer, so no hover, click or activation events fire.
Default false
GroupTransparency¶
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¶
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¶
MaxSize is the largest size layout gives the element; zero sets no limit. MinSize wins when it is larger.
Default UIVector.Zero
MinSize¶
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¶
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¶
SizeModeY is how the element's height is set, as SizeModeX sets the width.
Default "Fixed"
UIRoot¶
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¶
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¶
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¶
ScreenPosition is the laid-out top-left position of the element on screen, in UI points.
ScreenSize¶
ScreenSize is the laid-out width and height of the element on screen, in UI points.
Selectable¶
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¶
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¶
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¶
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¶
ArrowDirection is the direction the button's arrow points: "Left", "Right", "Up" or "Down".
Default "Right"
Clicked¶
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
Cursor¶
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¶
DragEnded fires on the client when the player finishes dragging this control. It passes true if the drag changed the control's value.
Example
Dragged¶
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¶
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¶
LinkUrl is the http:// or https:// address the button opens in the player's browser. Setting it underlines the button's text.
Default ""
Pressed¶
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
Released¶
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
RepeatDelay¶
RepeatDelay is how many seconds a button or arrow key is held before it repeats every RepeatInterval.
Default 0.275
RepeatInterval¶
RepeatInterval is the number of seconds between repeats while a button or key stays held.
Default 0.05
ShadeFill¶
ShadeFill, when true, lightens the fill of a clickable element under the pointer, and more while pressed.
Default false
WheelMoved¶
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¶
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
CharacterPhysics¶
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
CharacterSurfaceAlign¶
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¶
GetStateEnabled returns whether a character enters a movement state by itself. Every state is enabled until SetStateEnabled turns it off.
Example
GravityVector¶
GravityVector is the acceleration in units/s² that replaces world Gravity for this character.
Default Vector3.new(0, -196.2, 0)
NoContactFriction¶
NoContactFriction makes the character's colliders slide with no friction.
Default false
SetStateEnabled¶
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
State¶
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¶
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¶
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¶
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¶
AutoRotate turns the character to face the direction it walks. Shift lock turns it toward the camera direction instead.
Default false
HipHeight¶
HipHeight is how high, in units, the bottom of the torso stands above the ground.
Default 2
JumpPower¶
JumpPower is the speed, in units/s, a jump from the ground gives the character along UpDirection.
Default 50
JumpPowerScale¶
JumpPowerScale multiplies JumpPower for jumps in the air.
Default 1
MaxJumps¶
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¶
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¶
WalkSpeed is how fast the character walks, in units/s.
Default 16
CharacterRig¶
CharacterRig¶
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¶
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¶
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¶
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
Transparency¶
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¶
ConsolePrompt, when true, makes this element the developer console command input.
Default false
ConsoleRowLine¶
ConsoleRowLine, when true, makes this element show the text of a developer console message.
Default false
ConsoleRowPrefix¶
ConsoleRowPrefix, when true, makes this element show the time or source of a developer console message.
Default false
Decal¶
Layer¶
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¶
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¶
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
DirectionalLight¶
DirectionalColor¶
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¶
DirectionalEnergy is the brightness of the sunlight, from 0 to 20. At 0 surfaces get only ambient light.
Default 1
DirectionalShadowFill¶
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¶
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¶
MaxDistance is how far from the camera, in units, the sun casts shadows.
Default 500
DisplayName¶
DisplayName¶
DisplayName is the name on the character's nametag and in the player list.
Default ""
HingeJoint¶
ConnectedBody¶
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¶
HingeAnchor is the pivot of the hinge, in units in this part's frame.
Default Vector3.new(0, 0, 0)
HingeAxis¶
HingeAxis is the direction the hinge turns around, in this part's frame.
Default Vector3.new(1, 0, 0)
LimitsMax¶
LimitsMax is the upper angle limit of the hinge in degrees when UseLimits is true.
Default 0
LimitsMin¶
LimitsMin is the lower angle limit of the hinge in degrees when UseLimits is true.
Default 0
MotorForce¶
MotorForce is the most torque in Newton-meters the hinge motor applies. At 0 the motor does not turn the part.
Default 0
MotorTargetVelocity¶
MotorTargetVelocity is the speed of the hinge motor in degrees per second. A positive value turns counterclockwise around HingeAxis.
Default 0
UseLimits¶
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¶
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¶
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¶
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¶
Image is the asset id of the image drawn over the element's box. "0" draws none.
Default "0"
ImageColor¶
ImageColor tints the image: each pixel is multiplied by this color.
Default Vector3.new(1, 1, 1)
ImageRectOffset¶
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¶
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¶
ImageRotation turns the image clockwise by this many degrees about the element's center. Layout, clicks and children do not turn.
Default 0
ImageTransparency¶
ImageTransparency is the transparency of the image, from 0 (opaque) to 1 (invisible).
Default 0
PressedImage¶
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¶
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¶
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¶
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¶
SliceScale is the size of a "Slice" image's corners and edges as a multiple of their image size.
Default 1
TileSize¶
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¶
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.MoveCharacteris true.
Example
GetState¶
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¶
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¶
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¶
Down is a list of InputName values (InputBinding.Down, {} by default) that add -1 on Y to an "Axis2" action while held.
Input¶
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¶
At API 58 KeyCode is replaced by InputBinding.Inputs (for "Button" and "Axis1") and InputBinding.Stick (for "Axis2" thumbsticks).
Keybind¶
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¶
Left is a list of InputName values (InputBinding.Left, {} by default) that add -1 on X to an "Axis2" action while held.
Right¶
Right is a list of InputName values (InputBinding.Right, {} by default) that add +1 on X to an "Axis2" action while held.
UIButton¶
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¶
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¶
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¶
Priority is the order in which InputContext entities receive input, highest first. Contexts with the same priority all receive the input.
Default 1000
SelectionScope¶
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
SelectionGroupstops 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¶
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
Sinkstill 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¶
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
Light¶
InnerAngle¶
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¶
Intensity is the brightness of a point light or spotlight, from 0 to 1000, multiplied by LightColor.
Default 75
LightColor¶
LightColor is the sRGB color of a point light or spotlight.
Default Vector3.new(1, 1, 1)
LightShadowOff¶
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¶
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
Range¶
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¶
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
Mesh¶
Mesh¶
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¶
BackgroundTransparency is the transparency of the element's background, from 0 (opaque) to 1 (invisible).
Default 0
CornerRadii¶
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¶
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¶
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¶
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¶
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¶
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¶
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¶
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"
Popup¶
Options¶
Options is the choices of a dropdown, separated by commas. The chosen entry is the one at SelectedIndex.
Default ""
Popup¶
Popup, when true, closes the popup when the player clicks outside it.
Default false
PopupOpen¶
PopupOpen, when true, shows the popup panel above the rest of the interface.
Default false
Position¶
LocalPosition¶
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
LocalRotation¶
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
Position¶
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¶
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¶
Progress is how full the progress bar is, from 0 to 1, drawn clamped to that range.
Default 0
ProgressColor¶
ProgressColor is the color of a progress bar's fill.
Default Vector3.new(0.23, 0.51, 0.96)
ProgressTrackColor¶
ProgressTrackColor is the color of the track behind a progress bar's fill.
Default Vector3.new(1, 1, 1)
ProgressTrackTransparency¶
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¶
ProgressTransparency is the transparency of a progress bar's fill.
Default 0
BusyColor¶
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¶
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¶
BusyTransparency is the transparency of the moving segment of a busy progress bar.
Default 0
BusyWidth¶
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¶
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¶
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¶
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¶
LowerTranslation is the shortest Distance the rope motor reels in to. The motor stops there.
Default 0
MaximumMotorForce¶
MaximumMotorForce is the most force in Newtons the rope motor pulls with.
Default 10000
MotorSpeed¶
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
DistancebetweenLowerTranslationandUpperTranslation. A rope longer thanUpperTranslation, which is 5 by default, jumps to that length when its motor starts.
Example
RopeAnchor¶
RopeAnchor is where the rope attaches to this part, in units in its frame.
Default Vector3.new(0, 0, 0)
UpperTranslation¶
UpperTranslation is the longest Distance the rope motor reels out to. The motor stops there.
Default 5
Rotation¶
PivotPoint¶
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¶
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¶
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¶
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¶
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¶
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¶
ScrollFollowing, when true, keeps the frame scrolled to the bottom as children are added or the scroll area grows.
Default false
Shape¶
Type¶
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
RenderDisabled¶
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
ShadowOff¶
ShadowOff, when true, stops the entity from casting shadows. It still receives shadows.
Default false
Sound¶
Bus¶
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¶
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¶
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¶
ConeOuterGain is the volume multiplier outside ConeOuterAngle. 0 silences the sound there.
Default 0
Looped¶
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¶
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¶
Pause pauses a playing sound and keeps its place in the clip.
Example
Paused¶
Paused is true while the sound is paused partway through. Pause sets it; Resume and Stop clear it.
Default false
Play¶
Play starts the sound's clip from the beginning. The entity needs a Sound component.
Example
PlaybackSpeed¶
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¶
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¶
Resume plays a paused sound from where it stopped.
Example
RollOffMaxDistance¶
RollOffMaxDistance is the distance, in units, past which the sound cannot be heard.
Default 10000
RollOffMinDistance¶
RollOffMinDistance is the distance, in units, within which the sound plays at full volume.
Default 10
RollOffScale¶
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¶
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¶
Stop stops the sound and goes back to the start of the clip.
Example
Volume¶
Volume is how loud the sound plays. 0 is silent and 1 is the recorded loudness.
Default 0.5
SwingTwistJoint¶
Anchor¶
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¶
FrictionTorque is the torque in Newton-meters that keeps a settled swing-twist joint still. At 0 the joint turns freely.
Default 0
NormalCone¶
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¶
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¶
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¶
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¶
TwistMax is the upper rotation limit in degrees around TwistAxis, from the rest pose.
Default 45
TwistMin¶
TwistMin is the lower rotation limit in degrees around TwistAxis, from the rest pose.
Default -45
Timer¶
TimeLeft¶
TimeLeft is the number of seconds left on the countdown, or 0 when the timer is not running.
Default 0
Example
Timeout¶
Timeout fires each time the countdown reaches zero.
Example
TimerAutostart¶
TimerAutostart starts the timer from WaitTime when the entity enters the world, then sets itself back to false.
Default false
TimerOneShot¶
TimerOneShot stops the timer after one countdown. Without it, the timer starts over each time it fires.
Default false
TimerPaused¶
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¶
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¶
BoxColor is the fill color of a checkbox's box.
Default Vector3.new(1, 1, 1)
BoxTransparency¶
BoxTransparency is the transparency of a checkbox's box, from 0 (opaque) to 1 (invisible).
Default 0.94
CheckColor¶
CheckColor is the color of a checkbox's check mark.
Default Vector3.new(0.23, 0.51, 0.96)
CheckTransparency¶
CheckTransparency is the transparency of the check mark, from 0 (opaque) to 1 (invisible).
Default 0
Checked¶
Checked, when true, shows the checkbox's check mark. Clicking the checkbox flips it and fires Activated.
Default false
UIColorButton¶
SwatchColor¶
SwatchColor is the color of a color swatch button.
Default Vector3.new(1, 1, 1)
SwatchPreview¶
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¶
SwatchTransparency is the transparency of the color swatch.
Default 0
UIColorPicker¶
BarWidth¶
BarWidth is the width in pixels of the hue strip along the right edge of a color picker.
Default 20
Brightness¶
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¶
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¶
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¶
Canceled fires when the player cancels the dialog.
Example
CancelText¶
CancelText is the cancel button text; empty shows Cancel.
Default ""
Confirmed¶
Confirmed fires when the player accepts the dialog.
Example
ConfirmText¶
ConfirmText is the confirm button text; empty shows OK.
Default ""
DialogTitle¶
DialogTitle is the dialog's title.
Default ""
UIDock¶
DockPrefab¶
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¶
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¶
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¶
HeaderTransparency is the transparency of a collapsible section's header bar.
Default 0
UIGraph¶
GraphOffset¶
GraphOffset is how far a graph canvas is panned, in pixels.
Default Vector2.new(0, 0)
GraphZoom¶
GraphZoom is the zoom of a graph canvas.
Default 1
GraphZoomMax¶
GraphZoomMax is the highest zoom the mouse wheel reaches.
Default 2.0736
GraphZoomMin¶
GraphZoomMin is the lowest zoom the mouse wheel reaches.
Default 0.232568
GraphZoomStep¶
GraphZoomStep is the zoom factor of one mouse wheel notch.
Default 1.2
LinkFrom¶
LinkFrom is the graph port where a wire starts.
Default nil
LinkRequested¶
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¶
LinkTo is the graph port where a wire ends.
Default nil
PortColor¶
PortColor is the wire color of a graph port.
Default Vector3.new(1, 1, 1)
PortTransparency¶
PortTransparency is the wire transparency of a graph port.
Default 0
WireCurvature¶
WireCurvature is how much graph wires curve, from 0 (straight) to 1.
Default 0.5
UIGridLayout¶
CellPadding¶
CellPadding is the gap in pixels between neighboring cells of a grid, across and down.
Default 0
CellSize¶
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¶
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¶
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¶
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¶
FitColumns, when true, makes each grid column as wide as its widest cell.
Default false
FreezeRows¶
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¶
GridLineColor is the color of the lines between table cells.
Default Vector3.new(1, 1, 1)
GridLineThickness¶
GridLineThickness is the width in pixels of the lines between table cells; 0 draws none.
Default 1
GridLineTransparency¶
GridLineTransparency is the transparency of the lines between table cells, from 0 (opaque) to 1 (invisible).
Default 0.75
Margins¶
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¶
ResizableColumns, when true, lets players drag the dividers between table columns to resize them.
Default false
UIHitSlop¶
HitSlopBottom¶
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¶
HitSlopLeft is how many points left of the element's box the pointer still hits it; see HitSlopBottom for behavior.
Default 0
HitSlopRight¶
HitSlopRight is how many points right of the element's box the pointer still hits it; see HitSlopBottom for behavior.
Default 0
HitSlopTop¶
HitSlopTop is how many points above the element's box the pointer still hits it; see HitSlopBottom for behavior.
Default 0
UIIcon¶
IconAlign¶
IconAlign is the side of the text the icon goes on: "Left", "Right", "Top" or "Bottom".
Default "Left"
IconGap¶
IconGap is the gap in pixels between the icon and the text.
Default 6
IconSize¶
IconSize is the width and height in pixels of the icon.
Default 20
UIItemList¶
SelectedIndex¶
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¶
SelectionColor is the color of the highlight behind the selected list item.
Default Vector3.new(0.23, 0.51, 0.96)
SelectionTransparency¶
SelectionTransparency is the transparency of the highlight behind the selected list item, from 0 (opaque) to 1 (invisible).
Default 0.65
UIJoystick¶
StickCenter¶
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¶
StickDeadzone is how far the thumb must move, as a fraction of StickRadius, before StickDirection leaves (0, 0).
Default 0
StickDirection¶
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¶
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¶
StickRadius is how far, in pixels, the thumb can move from the center of the base.
Default 50
StickTip¶
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¶
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¶
ItemHeight is the height in pixels of every item of a long list. Below 1, children are not reused.
Default 30
ItemShown¶
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¶
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¶
Axis is the direction a list stacks its children: "Vertical" top to bottom, or "Horizontal" left to right.
Default "Vertical"
Justify¶
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¶
MarginBottom is the space in pixels inside the bottom edge of a list.
Default 0
MarginLeft¶
MarginLeft is the space in pixels inside the left edge of a list.
Default 0
MarginRight¶
MarginRight is the space in pixels inside the right edge of a list.
Default 0
MarginTop¶
MarginTop is the space in pixels inside the top edge of a list.
Default 0
Spacing¶
Spacing is the gap in pixels between a list's children along the direction it stacks them.
Default 0
UIListStripe¶
StripeColor¶
StripeColor is the color of every other line of a list or grid.
Default Vector3.new(1, 1, 1)
StripeTransparency¶
StripeTransparency is the transparency of the stripes, from 0 (opaque) to 1 (invisible).
Default 0.94
UIMenu¶
HighlightColor¶
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¶
HighlightTransparency is the transparency of the background of a menu item or dropdown entry under the pointer.
Default 0
MenuCheck¶
MenuCheck, when true, makes a menu item keep room at its left edge for a check mark or radio dot.
Default false
Open¶
Open, when true, opens the dropdown's list. A click outside sets it to false.
Default false
PanelColor¶
PanelColor is the background color of a popup menu or dropdown list.
Default Vector3.new(0.12, 0.12, 0.14)
PanelTransparency¶
PanelTransparency is the transparency of a popup menu or dropdown list's background.
Default 0.04
Radio¶
Radio, when true, draws a round radio dot in place of a square check mark.
Default false
Shortcut¶
Shortcut is text shown at the right of a menu item, such as "Ctrl+S". It does not bind the key.
Default ""
UIMultiSelect¶
MultiSelectColor¶
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¶
MultiSelectTransparency is the transparency of the multi-select drag box and the highlight behind each selected child.
Default 0.65
MultiSelected¶
MultiSelected, when true, makes the element part of the current multiple selection.
Default false
UINumberField¶
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¶
NumberMax is the highest value the player can enter.
Default 100
NumberMin¶
NumberMin is the lowest value the player can enter.
Default 0
NumberStep¶
NumberStep is how much a number field changes per drag step or arrow key. 0 lets the value change smoothly.
Default 1
UIPlot¶
PlotColor¶
PlotColor is the color of a plot's lines or bars.
Default Vector3.new(0.23, 0.51, 0.96)
PlotTransparency¶
PlotTransparency is the transparency of a plot's lines or bars.
Default 0
PlotType¶
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¶
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¶
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¶
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¶
FillAmount is how much of a round progress fill shows, from 0 (empty) to 1 (the full circle).
Default 1
FillMode¶
FillMode is the way a round progress fill sweeps: "Clockwise", "Counterclockwise", or "BothWays" from the top center.
Default "Clockwise"
UIRadioButton¶
CircleColor¶
CircleColor is the color of a radio button's outer ring.
Default Vector3.new(1, 1, 1)
CircleTransparency¶
CircleTransparency is the transparency of a radio button's outer ring, from 0 (opaque) to 1 (invisible).
Default 0.94
DotColor¶
DotColor is the color of the dot of a selected radio button.
Default Vector3.new(0.23, 0.51, 0.96)
DotTransparency¶
DotTransparency is the transparency of a radio button's dot, from 0 (opaque) to 1 (invisible).
Default 0
RadioGroup¶
RadioGroup is the number that ties radio buttons together: selecting one unselects the others with the same number.
Default 0
Selected¶
Selected, when true, makes this radio button the chosen option of its group.
Default false
UIScreenInsets¶
InsetEdge¶
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¶
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¶
ScrollBarMax is the end of a scroll bar's range, in units the script picks.
Default 100
ScrollBarMin¶
ScrollBarMin is the start of a scroll bar's range, in units the script picks.
Default 0
ScrollBarPage¶
ScrollBarPage is how much of a scroll bar's range shows at once, in the units of ScrollBarMin and ScrollBarMax.
Default 10
ScrollBarValue¶
ScrollBarValue is the scroll position. Dragging or clicking the bar changes it and keeps it between ScrollBarMin and ScrollBarMax - ScrollBarPage.
Default 0
UISeparator¶
LabelText¶
LabelText is text drawn centered in a separator line, splitting it in two. An empty string draws a plain line.
Default ""
LineColor¶
LineColor is the color of a separator's line.
Default Vector3.new(0.43, 0.43, 0.5)
LineThickness¶
LineThickness is the thickness in pixels of a separator's line.
Default 1
LineTransparency¶
LineTransparency is the transparency of a separator's line.
Default 0.5
UISlider¶
FillColor¶
FillColor is the color of the slider track between its start and the thumb.
Default Vector3.new(0.23, 0.51, 0.96)
FillImage¶
FillImage is the asset id of the image on the filled part of the slider track. "0" draws plain FillColor.
Default "0"
FillTransparency¶
FillTransparency is the transparency of the filled part of the slider track, from 0 (opaque) to 1 (invisible).
Default 0
HighValue¶
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¶
MaxValue is the highest value of a slider.
Default 1
MinValue¶
MinValue is the lowest value of a slider.
Default 0
SliderFormat¶
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¶
SliderValue is the current value of a slider. Dragging moves it between MinValue and MaxValue and fires Activated.
Default 0
Steps¶
Steps is the number of stops along a slider's track, from 2 to 255.
Default 2
ThumbColor¶
ThumbColor is the color of the slider's thumb.
Default Vector3.new(0.23, 0.51, 0.96)
ThumbCornerRadius¶
ThumbCornerRadius is the corner radius in pixels, 0 to 1000, of the slider's thumb. 0 draws a round thumb.
Default 0
ThumbImage¶
ThumbImage is the asset id of the image on the slider's thumb. "0" draws a plain thumb in ThumbColor.
Default "0"
ThumbSize¶
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¶
ThumbTransparency is the transparency of the slider's thumb, from 0 (opaque) to 1 (invisible).
Default 0
TickColor¶
TickColor is the color of the tick marks along the slider's track.
Default Vector3.new(1, 1, 1)
TickLength¶
TickLength is the length in pixels, 0 to 1000, of the tick marks across the slider's track; 0 draws none.
Default 8
TickTransparency¶
TickTransparency is the transparency of the tick marks, from 0 (opaque) to 1 (invisible).
Default 0.75
TrackAxis¶
TrackAxis is the way the slider runs: "Horizontal" left to right, or "Vertical" up and down.
Default "Horizontal"
TrackColor¶
TrackColor is the color of the unfilled part of the slider's track.
Default Vector3.new(1, 1, 1)
TrackImage¶
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¶
TrackThickness is the thickness in pixels, 0 to 1000, of the slider's track.
Default 6
TrackTransparency¶
TrackTransparency is the transparency of the unfilled track, from 0 (opaque) to 1 (invisible).
Default 0.94
Value¶
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¶
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¶
SurfaceCanvasSizeY is the height in pixels of the 2D canvas drawn on a face of the parent part.
Default 600
SurfaceFace¶
SurfaceFace is the face of the parent part the surface UI draws on: "Right", "Top", "Back", "Left", "Bottom" or "Front".
Default "Front"
SurfaceLightInfluence¶
SurfaceLightInfluence is how much scene lighting shades the surface canvas, from 0 (always full brightness) to 255 (lit like the scene).
Default 255
SurfaceMaxDistance¶
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¶
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¶
UISurfaceAlwaysOnTop, when true, draws the surface UI in front of everything in the 3D scene.
Default false
UITableHeader¶
HeaderCell¶
HeaderCell, when true, makes the grid cell look and work as a clickable column header.
Default false
SortColumn¶
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¶
SortDescending, when true, sorts the table from highest to lowest.
Default false
UITabs¶
SelectedTabColor¶
SelectedTabColor is the color of the open tab's button.
Default Vector3.new(59/255, 130/255, 245/255)
SelectedTabTransparency¶
SelectedTabTransparency is the transparency of the open tab's button.
Default 0
TabColor¶
TabColor is the color of the buttons of tabs that are not open.
Default Vector3.new(31/255, 31/255, 36/255)
TabTransparency¶
TabTransparency is the transparency of the buttons of tabs that are not open.
Default 0
UITextInput¶
CursorColor¶
CursorColor is the color of the blinking caret of a text box being typed in.
Default Vector3.new(1, 1, 1)
CursorPosition¶
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¶
CursorTransparency is the transparency of the caret, from 0 (opaque) to 1 (invisible).
Default 0
Focused¶
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¶
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¶
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¶
Password, when true, shows asterisks in the text box in place of what the player types. Text keeps the real characters.
Default false
PlaceholderColor¶
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¶
PlaceholderText is the hint a text box shows while its Text is empty and it is not being typed in.
Default ""
ReleaseFocus¶
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
SearchBox¶
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¶
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¶
Bold reads true when FontWeight is 600 or more. Writing true sets FontWeight to 700 and false sets it to 400.
Default false
FontFamily¶
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¶
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¶
Italic, when true, slants the text by 14 degrees.
Default false
LineHeight¶
LineHeight is the spacing of text lines as a multiple of the font's line spacing, from 1 to 3.
Default 1
NoTranslate¶
NoTranslate, when true, shows the element's Text as written, never translated to the player's language.
Default false
RichText¶
RichText, when true, draws Text as markup with lowercase <b> (weight 700), <i>, <font color weight>, <br /> and the < > " ' & escapes. Markup that does not parse draws as written, and a text box ignores RichText.
Default false
Example
Text¶
Text is the text of a label, text box or button. With a "Fit" size mode, the element sizes to it.
Default ""
TextColor¶
TextColor is the color of the text.
Default Vector3.new(1, 1, 1)
TextSize¶
TextSize is the height of the text in pixels, from 1 to 512.
Default 14
TextStrokeColor¶
TextStrokeColor is the color of the outline around the text.
Default Vector3.new(0, 0, 0)
TextStrokeScale¶
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¶
TextStrokeTransparency is the transparency of the text outline, from 0 (opaque) to 1 (invisible).
Default 1
TextStrokeWidth¶
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¶
TextTransparency is the transparency of the text, from 0 (opaque) to 1 (invisible).
Default 0
TextTruncate¶
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¶
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¶
TextXAlignment aligns the text horizontally in the element: "Left", "Center" or "Right".
Default "Left"
TextYAlignment¶
TextYAlignment aligns the text vertically in the element: "Top", "Center" or "Bottom".
Default "Top"
UIToggle¶
KnobColor¶
KnobColor is the color of a toggle switch's knob.
Default Vector3.new(1, 1, 1)
KnobImage¶
KnobImage is the asset id of the image on a toggle switch's knob. "0" draws a plain knob in KnobColor.
Default "0"
KnobInset¶
KnobInset is the gap in pixels between a toggle switch's track and knob.
Default 2
KnobTransparency¶
KnobTransparency is the transparency of a toggle switch's knob, from 0 (opaque) to 1 (invisible).
Default 0
Mixed¶
Mixed, when true, places a toggle switch's knob in the middle. Clicking clears Mixed and flips On.
Default false
OffColor¶
OffColor is the color of a toggle switch's track while On is false.
Default Vector3.new(1, 1, 1)
OffImage¶
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¶
OffTransparency is the transparency of a toggle switch's track while it is off, from 0 (opaque) to 1 (invisible).
Default 0.94
On¶
On is whether a toggle switch or UIToggleButton is on. Clicking flips it and fires Activated.
Default false
OnColor¶
OnColor is the color of a toggle switch's track while On is true.
Default Vector3.new(0.23, 0.51, 0.96)
OnImage¶
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¶
OnTransparency is the transparency of a toggle switch's track while it is on, from 0 (opaque) to 1 (invisible).
Default 0
SwitchWidth¶
SwitchWidth is the width in pixels of a toggle switch's track; 0 makes it twice the element's height.
Default 0
TogglePrefab¶
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¶
ToggleTarget is the UIRoot that TogglePrefab names, or nil while none exists.
Default nil
UIToggleButton¶
UIToggleButton, when true, makes the button stay pressed after a click and pop back up on the next click.
Default false
UITreeView¶
BranchColor¶
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¶
BranchTransparency is the transparency of the tree view lines.
Default 0
Folded¶
Folded, when true, collapses the tree node and hides everything under it.
Default false
Indent¶
Indent is how far, in pixels, each level of a tree view moves its children to the right.
Default 16
UIVectorField¶
VectorCount¶
VectorCount is how many fields a vector input shows: 2 (X, Y) or 3 (X, Y, Z).
Default 3
VectorMax¶
VectorMax is the highest value a vector input's fields take, ignored at or below VectorMin.
Default 0
VectorMin¶
VectorMin is the lowest value a vector input's fields take, ignored at or above VectorMax.
Default 0
VectorSpeed¶
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¶
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¶
GripSize is the size in pixels of the square resize handle in a window's corner.
Default 16
TitleHeight¶
TitleHeight is the height in pixels of a window's title bar, which the player drags to move the window.
Default 32
Floating¶
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¶
Angle turns the texture, in degrees, around the UV center (0.5, 0.5).
Default 0
Offset¶
Offset slides the texture by X and Y texture widths along U and V; Z is ignored.
Default Vector3.new(0, 0, 0)
Example
Tiling¶
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¶
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
Weld¶
BreakForce¶
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¶
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¶
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¶
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¶
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¶
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¶
DriveTorque is the most torque the wheel's motor applies to reach SpinSpeed. At 0 the wheel rolls freely.
Default 0
LongitudinalStiffness¶
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¶
MaxSteerTorque is the most torque the steering spring applies to turn a Steers wheel. 0 does not limit the spring.
Default 0
Mount¶
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¶
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¶
RollingResistance (TirePatchConfig) is the torque against a tire's rolling, as a fraction of its load.
Default 0.015
SpinSpeed¶
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¶
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¶
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¶
SteerLimit is how far in degrees a Steers wheel may turn either way. At 0 the wheel stays straight.
Default 0
SteerTarget¶
SteerTarget is the angle in degrees the steering spring turns a Steers wheel toward, within SteerLimit.
Default 0
Steers¶
Steers lets a wheel turn about the chassis's up direction toward SteerTarget.
Default false
Example
SuspensionDamping¶
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¶
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¶
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¶
SuspensionMaxLength (RaycastSuspension) is the farthest the wheel hangs from SuspensionHardpoint, in units. Past it the wheel leaves the ground.
Default 7
SuspensionMinLength¶
SuspensionMinLength (RaycastSuspension) is the shortest the suspension compresses to, in units. The spring pushes no harder past it.
Default -1
SuspensionRestLength¶
SuspensionRestLength (RaycastSuspension) is the distance in units from SuspensionHardpoint where the spring pushes with no force.
Default 3
SuspensionStiffness¶
SuspensionStiffness (RaycastSuspension) is the spring force per unit of compression, as a multiple of the parent part's mass.
Default 5.88
SuspensionWheelRadius¶
SuspensionWheelRadius (RaycastSuspension) is the radius of the wheel in units for the raycast suspension.
Default 10
Travel¶
Travel is how far in units a WheelJoint moves up and down from its Mount. 0 is a rigid axle.
Default 0.5
WheelRadius¶
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