PcoWSkbVqDnWTu_dm2ix
Laser Traps with Beams
Part 2 - Customizing the Beam
Laser Traps with Beams
Part 2 - Customizing the Beam

Beam Properties

Beams use 2D images that can be customized with properties to affect the color, size, or curvature.

  1. Copy the asset ID of an image you uploaded, or copy an ID from the examples below.
rbxassetid://6060542021
rbxassetid://6060542158
rbxassetid://6060542252
  1. In the beam’s Texture property, paste the asset ID.
  1. 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).
  1. Make the beam wider by setting both Width0 and Width1 to 4.
  1. The TextureSpeed property animates the texture over time. For a fast, flickering effect, set it to 3.
  1. Make the laser look a bit more dangerous by changing its Color property.
Repeating or Static Textures

Textures have different modes, the default being Stretch which stretches the texture between the two attachments. Depending on your beam, you may want an alternative like Wrap or Static. Learn more on the TextureMode page.


Trap Mechanic

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.

  1. In LaserTrap, create a new part named CollisionBox that overlaps the beam.
  1. Anchor CollisionBox so it doesn’t move.

    alt

  2. 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.Parent
    local collisionBox = laserTrap:FindFirstChild("CollisionBox") 
    
    -- Hide the collision box
    collisionBox.Transparency = 1
    
    local function onTouch(otherPart)
      local character = otherPart.Parent
      local humanoid = character:FindFirstChildWhichIsA("Humanoid")
    
      if humanoid then
        humanoid.Health = 0
      end
    end
    
    collisionBox.Touched:Connect(onTouch)
  3. 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.


Previous Page Getting Started