Roblox UtilitiesDevlHub Roblox Documentation

Class

Beam

Inherits
Instance › Object
Memory category
Instances

Connects two Attachments by drawing a texture between them.

A Beam object connects two Attachments by drawing a texture between them.

To display, a beam must be a descendant of the Workspace with its Attachment0 and Attachment1 properties set to Attachments also descending from the Workspace.

The beam's appearance can be customized using the range of properties outlined below. Also see the Beams guide for visual examples.

Beam Curvature#

Beams are configured to use a cubic Bézier curve formed by four control points. This means they are not constrained to straight lines and the curve of the beam can be modified by changing CurveSize0, CurveSize1, and the orientation of the beam's Attachments.

Beam curvature diagram

Properties 21#

Attachment0AttachmentThe Attachment the beam originates from.ReadSafe
Attachment1AttachmentThe Attachment the beam ends at.ReadSafe
BrightnessfloatScales the light emitted from the beam when LightInfluence is less than 1.ReadSafe
ColorColorSequenceDetermines the color of the beam across its Segments.ReadSafe
CurveSize0floatDetermines, along with Attachment0, the position of the second control point in the beam's Bézier curve.ReadSafe
CurveSize1floatDetermines, along with Attachment1, the position of the third control point in the beam's Bézier curve.ReadSafe
EnabledbooleanDetermines whether the beam is visible or not.ReadSafe
FaceCamerabooleanDetermines whether the Segments of the beam will always face the camera, regardless of its orientation.ReadSafe
LightEmissionfloatDetermines to what degree the colors of the beam are blended with the colors behind it.ReadSafe
LightInfluencefloatDetermines the degree to which the beam is influenced by the environment's lighting.ReadSafe
LocalTransparencyModifierfloatDetermines a multiplier for Beam.Transparency that is only visible to the local client.ReadSafeHiddenNotReplicated
SegmentsintSets how many straight segments the beam is made up of.ReadSafe
TextureContentIdThe content ID of the texture to be displayed on the beam.ReadSafe
TextureContentContentThe texture displayed on the beam. Supports asset URIs.ReadSafe
TextureLengthfloatSets the length of the beam's texture, dependent on TextureMode.ReadSafe
TextureModeTextureModeDetermines the manner in which the Texture scales and repeats.ReadSafe
TextureSpeedfloatDetermines the speed at which the Texture image moves along the beam.ReadSafe
TransparencyNumberSequenceDetermines the transparency of the beam across its segments.ReadSafe
Width0floatThe width of the beam at its origin (Attachment0), in studs.ReadSafe
Width1floatThe width of the beam at its end (Attachment1), in studs.ReadSafe
ZOffsetfloatThe distance, in studs, the beam display is offset relative to the CurrentCamera.ReadSafe

Attachment0: Attachment#

ReadSafe

The Attachment the beam originates from. This attachment is the first control point on the beam's cubic Bézier curve; its orientation, alongside the CurveSize0 property, determines the position of the second control point. See Beams for more details.

For the Attachment where the beam ends, see Attachment1.

Attachment1: Attachment#

ReadSafe

The Attachment the beam ends at. This attachment is the fourth and final control point on the beam's cubic Bézier curve; its orientation, alongside the CurveSize1 property, determines the position of the third control point. See Beams for more details.

For the Attachment where the beam originates from, see Attachment0.

Brightness: float#

ReadSafe

Scales the light emitted from the beam when LightInfluence is less than 1. This property is 1 by default and can set to any number within the range of 0 to 10000. Increasing the value of LightInfluence decreases the effect of this property's value.

Color: ColorSequence#

ReadSafe

Determines the color of the beam across its Segments. If Texture is set, this color will be applied to the beam's texture. If no Texture is set, the Beam will appear as a solid line colored in accordance with this property.

This property is a ColorSequence, allowing the color to be configured to vary across the length of the beam. Consider the following ColorSequence which, when applied to a beam, would yield the pictured result.

Luau
local colorSequence = ColorSequence.new({
		ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)), -- Red
		ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 188, 203)), -- Cyan
		ColorSequenceKeypoint.new(1, Color3.fromRGB(196, 0, 255)), -- Purple
	}
)

Note the beam's coloration also depends on the number of Segments the Beam has. Each segment of the beam can only show a transition between two colors. Therefore a Beam will need to have at least n-1 segments in order for the color to display correctly, where n is the number of ColorSequenceKeypoints in the ColorSequence.

CurveSize0: float#

ReadSafe

Determines, along with Attachment0, the position of the second control point in the beam's Bézier curve. See Beams for more details.

The position of this point can be determined by the following equation:

CurveSize1: float#

ReadSafe

Determines, along with Attachment1, the position of the third control point in the beam's Bézier curve. See Beams for more details.

The position of this point can be determined by the following equation:

Enabled: boolean#

ReadSafe

Determines whether the beam is visible or not.

When this property is set to false, the beam's Segments will not be displayed.

FaceCamera: boolean#

ReadSafe

A Beam is a 2D projection existing in 3D space, meaning that it may not be visible from every angle. The FaceCamera property, when set to true, ensures that the beam always faces the CurrentCamera, regardless of its orientation.

LightEmission: float#

ReadSafe

Determines to what degree the colors of the beam are blended with the colors behind it. It should be set in the range of 0 to 1. A value of 0 uses normal blending modes and a value of 1 uses additive blending.

This property should not be confused with LightInfluence which determines how the beam is affected by environmental light.

This property does not cause the beam to light the environment.

LightInfluence: float#

ReadSafe

Determines the degree to which the beam is influenced by the environment's lighting, clamped between 0 and 1. When 0, the beam will be unaffected by the environment's lighting. When 1, it will be fully affected by lighting as a BasePart would be.

See also LightEmission which specifies to what degree the colors of the beam are blended with the colors behind it.

LocalTransparencyModifier: float#

HiddenNotReplicatedReadSafe

The LocalTransparencyModifier property is a multiplier applied to the beam's Transparency that is only visible to the local client. It does not replicate from client to server and is useful for when a beam should not render for a specific client.

Uses the same formula as BasePart.LocalTransparencyModifier.

A value of 0 (default) has no effect on the beam's transparency. A value of 1 makes the beam completely invisible to the local client regardless of its Transparency value.

Segments: int#

ReadSafe

Rather than being a perfect curve, a beam is made up of straight segments. The more segments, the higher the resolution of the curve. The Segments property sets how many straight segments the beam is made up of, with a default value of 10.

Note that the Color and Transparency properties require a certain number of segments to display correctly. This is because each segment can only show a transition between two colors or transparencies. Therefore a Beam requires at least n-1 segments to display correctly, where n is the number of keypoint associated with the beam's Color and Transparency.

Texture: ContentId#

ReadSafe

The content ID of the texture to be displayed on the beam. If this property is not set, the beam will be displayed as a solid line; this also occurs when the texture is set to an invalid content ID or the image associated with the texture has not yet loaded.

The appearance of the texture can be further modified by other beam properties including Color and Transparency.

Scaling of the texture is determined by the TextureMode, TextureLength, Width0, and Width1 properties.

TextureContent: Content#

ReadSafe

The texture displayed on the beam. Supports asset URIs.

If this property is set to Content.none, the beam displays as a solid line colored by its Color property. The appearance of the texture can be further modified by Color, Transparency, and scaling is determined by TextureMode, TextureLength, Width0, and Width1.

TextureLength: float#

ReadSafe

Sets the length of the beam's texture, dependent on TextureMode.

TextureMode: TextureMode#

ReadSafe

This property, alongside TextureLength, determines how a beam's Texture repeats.

When set to TextureMode.Wrap or TextureMode.Static, the texture repetitions will equal the beam's overall length (in studs) divided by its TextureLength.

TextureMode diagram with Wrap mode

When set to TextureMode.Stretch, the texture will repeat TextureLength times across the beam's overall length.

TextureMode diagram with Stretch mode

TextureSpeed: float#

ReadSafe

Sets the number of texture cycles per second at which the Texture image moves along the beam, where one cycle is a full traversal of the texture's UV range. When this property is a positive value, the beam's texture will move from Attachment0 to Attachment1. This direction can be inverted by setting this property to a negative number. The default value is 1.

How far one cycle travels along the beam in studs depends on TextureMode and TextureLength.

Examples#

Transparency: NumberSequence#

ReadSafe

Determines the transparency of the beam across its segments. This property is a NumberSequence, allowing the transparency to be configured to vary across the length of the beam.

Consider the following NumberSequence which, when applied to a beam, would yield the pictured result.

Luau
local numberSequence = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 0), -- Opaque
		NumberSequenceKeypoint.new(0.5, 1), -- Transparent
		NumberSequenceKeypoint.new(1, 0), -- Opaque
	}
)

Note that the beam's transparency also depends on the number of Segments. Each segment of the beam can only show a transition between two transparencies. Therefore a beam will need to have at least n-1 segments in order to display correctly, where n is the number of NumberSequenceKeypoints in the NumberSequence.

Width0: float#

ReadSafe

The width of the beam at its origin (Attachment0), in studs. The beam's width will change linearly to Width1 studs at its end (Attachment1).

Width1: float#

ReadSafe

The width of the beam at its end (Attachment1), in studs. The beam's width will change linearly from Width0 studs at its origin (Attachment0).

ZOffset: float#

ReadSafe

The distance, in studs, the beam display is offset relative to the CurrentCamera. When 0, the beam will be displayed in its standard position between Attachment0 and Attachment1. ZOffset can be either positive or negative.

This property is particularly useful to avoid "Z‑fighting" when using multiple Beams between the same Attachments.

Methods 1#

SetTextureOffsetSets the current offset of the beam's texture cycle.

SetTextureOffset(offset: float = 0): ()#

The offset of a beam's texture cycle represents the progress of its texture animation. This method sets the current offset of the beam's texture cycle; hence, it can be used to reset the cycle by passing 0 as the offset parameter.

Notes#

  • The given offset parameter is expected to be a value between 0 and 1, but greater values can be used.
  • The texture cycle wraps at 0 and 1, meaning the texture is in the same position when the offset is at 0 or 1.
  • If the Texture property is not set, this method does nothing.
  • Increasing the offset will act in the inverse direction to the TextureSpeed property, meaning it will move the texture in the opposite direction to the direction the texture animates when TextureSpeed is greater than 0.
NameTypeDefaultDescription
offsetfloat0The desired offset of the texture cycle.
Returns
  • ()

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed