Guest User

Untitled

a guest
Oct 9th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local tool = script.Parent
  2. local player = game:GetService("Players").LocalPlayer
  3.  
  4. tool.Equipped:connect(function(mouse)
  5.  
  6.     mouse.Button1Down:connect(function()
  7.         local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
  8.         local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
  9.  
  10.         local beam = Instance.new("Part", workspace)
  11.         beam.BrickColor = BrickColor.new("Bright red")
  12.         beam.FormFactor = "Custom"
  13.         beam.Material = "Neon"
  14.         beam.Anchored = true
  15.         beam.Locked = true
  16.         beam.CanCollide = false
  17.  
  18.         local distance = (tool.Handle.CFrame.p - position).magnitude
  19.         beam.Size = Vector3.new(0.3, 0.3, distance)
  20.         beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
  21.  
  22.         game:GetService("Debris"):AddItem(beam, 0.03)
  23.  
  24.         if part then
  25.             local humanoid = part.Parent:FindFirstChild("Humanoid")
  26.  
  27.             if not humanoid then
  28.                 humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  29.             end
  30.  
  31.             if humanoid then
  32.                 humanoid:TakeDamage(30)
  33.             end
  34.         end
  35.     end)
  36. end)
Add Comment
Please, Sign In to add comment