Codectionary / Developer documentation / Luau

Beam effects

Draw an effect between two attachments.

Why use Beam?

A Beam visually connects Attachment0 and Attachment1. It suits lasers, links, and trails that must follow moving endpoints; the beam itself does not apply damage or physics.

Try it in Roblox Studio

Create Parts named StartPost and EndPost in Workspace. Put this Script in ServerScriptService and move the parts to see the effect follow them.

Syntax

beam.Attachment0 = startAttachment
beam.Attachment1 = endAttachment

Examples

Beam effects

Connect two posts with a visible beam.

local startPost = workspace:WaitForChild("StartPost")
local endPost = workspace:WaitForChild("EndPost")
assert(startPost:IsA("BasePart") and endPost:IsA("BasePart"))
local startAttachment = Instance.new("Attachment")
startAttachment.Parent = startPost
local endAttachment = Instance.new("Attachment")
endAttachment.Parent = endPost

local beam = Instance.new("Beam")
beam.Attachment0 = startAttachment
beam.Attachment1 = endAttachment
beam.Width0 = 0.2
beam.Width1 = 0.2
beam.Color = ColorSequence.new(Color3.fromRGB(0, 170, 255))
beam.Parent = startPost
  1. Each attachment tracks its parent part’s position.
  2. The beam uses those endpoints and a ColorSequence to draw a visual connection.
  3. Moving either post changes the beam; collision and gameplay rules need separate code.

Best practices

  • Keep beam widths and textures legible at the intended camera distance.
  • Use raycasting separately if the effect is supposed to hit objects.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading