Beams are an effect that can be used to create lasers, force fields, and even waterfalls. This object draws a texture between two points with customizable properties like speed, width, and curve.
In this tutorial, you'll create a laser trap that uses a beam and insert a script to set a player's health to 0 when the trap is touched.
Attachments are where one object can connect to another. In this case, attachments will be used for the start and end points of the beam.
Attachments aren't normally visible. To view attachments, toggle on Constraint Details in the Model tab.
Create an anchored part or model named LaserTrap. Then, add two attachments named StartAttachment and EndAttachment.
New attachments are created in the center of the part. For the beam, the attachments will need to be moved into position.
Select StartAttachment (1) and use the Move tool to position it at the edge of the laser trap.
Move EndAttachment (2) further away to where the laser should stop.
Create the Beam
With the attachments in place, a beam can now be created.
Under LaserTrap, add a Beam object named Laser.
With Laser selected, find Attachment0 in the Properties window. Click the empty box to the right of the property and then, in the Explorer, click StartAttachment.
Set Attachment1 to EndAttachment using the same process. The properties should appear as below.
By default, a beam doesn't always face the camera. This may lead to situations where players are unable to see a beam from different angles.Left ViewTop View
So the beam is visible at any position, go into the beam properties and enable FaceCamera.
Beams use 2D images that can be customized with properties to affect the color, size, or curvature.
Copy the asset ID of an image you uploaded, or copy an ID from the examples below.
In the beam's Texture property, paste the asset ID.
Make the laser appear brighter by changing a few properties.
- Add a faint glow by changing the LightEmission property to 0.5.
- Change Transparency to 0 (fully opaque).
Make the beam wider by setting both Width0 and Width1 to 4.
The TextureSpeed property animates the texture over time. For a fast, flickering effect, set it to 3.
Make the laser look a bit more dangerous by changing its Color property.
The script for the trap will check if an invisible part is touches a player. The part is used since beams don't have collision detection by default.
In LaserTrap, create a new part named CollisionBox that overlaps the beam.
Anchor CollisionBox so it doesn't move.
In the main model or part named LaserTrap, add a new script. Copy the code below and paste it into the new script.local laserTrap = script.Parentlocal collisionBox = laserTrap:FindFirstChild("CollisionBox")-- Hide the collision boxcollisionBox.Transparency = 1local function onTouch(otherPart)local character = otherPart.Parentlocal humanoid = character:FindFirstChildWhichIsA("Humanoid")if humanoid thenhumanoid.Health = 0endendcollisionBox.Touched:Connect(onTouch)
Test the trap by walking into the laser beam. If it's not working correctly, make sure the script is in the right place and the collision box is properly named.
With the beam complete, explore additional beam properties like CurveSize0 and CurveSize1, import your own textures, or even make a new object like a force field.