Advertisement
scriptingtales

Roblox beam tool

Jun 8th, 2023
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local tool = Instance.new("Tool")
  2. tool.RequiresHandle = false
  3. tool.Name = "BeamTool"
  4.  
  5. tool.Activated:Connect(function()
  6.     local mouse = owner:GetMouse()
  7.     local beam = Instance.new("Beam", game.Workspace)
  8.     beam.FaceCamera = true
  9.     beam.Color = ColorSequence.new(Color3.new(1, 0, 0))
  10.     beam.Transparency = NumberSequence.new(0, 1)
  11.     beam.Width0 = 1
  12.     beam.Width1 = 5
  13.     beam.Segments = 10
  14.  
  15.     local startPos = mouse.Hit.p
  16.     while true do
  17.         local endPos = mouse.Hit.p
  18.         local distance = (startPos - endPos).magnitude
  19.         if distance > 4 then
  20.             beam.Attachment0 = Instance.new("Attachment", game.Workspace.Terrain)
  21.             beam.Attachment0.Position = startPos
  22.             beam.Attachment1 = Instance.new("Attachment", game.Workspace.Terrain)
  23.             beam.Attachment1.Position = endPos
  24.             break
  25.         end
  26.         wait()
  27.     end
  28.  
  29.     local duration = 1 -- Change the duration as required
  30.     local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
  31.     local transparencyGoal = {Transparency = 1}
  32.     local tween = game:GetService("TweenService"):Create(beam, tweenInfo, transparencyGoal)
  33.     tween:Play()
  34.     tween.Completed:Connect(function()
  35.         beam:Destroy()
  36.     end)
  37. end)
  38.  
  39. tool.Parent = owner.Backpack
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement