Advertisement
Sarah67853

Laser arm(Press R to actavate)

Jul 24th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. --[[
  2. LAZ0R H4ND MADE BY THE ONE AND ONLY X1OP.
  3. Instructions: to toggle press R and to shoot a ray just click.
  4. It needs to be a localscript.
  5. Have fun!
  6. ]]
  7. local Player=game:GetService("Players").LocalPlayer
  8. local RayColor=BrickColor.new("Tan")
  9. local Mouse=Player:GetMouse()
  10. local Damage=25
  11. local infDamage=true
  12. local Render=game:GetService("RunService").RenderStepped
  13. local function BEGIN(Character)
  14. local WhenYouStop={}
  15. local MouseConnection
  16. local RightArm=Character:FindFirstChild("Right Arm")
  17. if RightArm==nil then return end
  18. local Torso=Character:FindFirstChild("Torso")
  19. if Torso==nil then return end
  20. local RightShoulder
  21. if Torso then
  22. RightShoulder=Torso:FindFirstChild("Right Shoulder")
  23. if RightShoulder then
  24. RightShoulder=RightShoulder:clone()
  25. end
  26. end
  27. local RayPowers=false
  28. local function START()
  29. if RayPowers==false then
  30. local Weld=Instance.new("Weld",Character)
  31. Weld.Part0=Torso
  32. Weld.Part1=RightArm
  33. MouseConnection=Mouse.Button1Down:connect(function()
  34. local function RayCast(Origin,Destination,Character)
  35. local togo=(Destination-Origin).unit
  36. local ray=Ray.new( Origin, (togo*999) )
  37. local HitPart,HitPoint=Workspace:FindPartOnRay(ray,Character)
  38. coroutine.wrap(function()
  39. local d=Instance.new("Sound",Character.Torso)
  40. d.SoundId="http://www.roblox.com/asset/?id=130791043"
  41. d.Volume=2
  42. d:Play()
  43. wait(1)
  44. d:Destroy()
  45. end)()
  46. if HitPart then
  47. for i,v in pairs(HitPart.Parent:GetChildren()) do
  48. if v.className=="Humanoid" then
  49. if infDamage then
  50. v.Health=0
  51. else
  52. v.Health=v.Health-Damage
  53. end
  54. end
  55. end
  56. if HitPart.Parent:IsA("Hat") then
  57. HitPart:Destroy()
  58. end
  59. local prt=Instance.new("Part",Workspace)
  60. prt.BrickColor=RayColor
  61. prt.FormFactor="Custom"
  62. prt.Anchored=true
  63. prt.CanCollide=false
  64. prt.Size=Vector3.new(RightArm.Size.x,(HitPoint-Origin).magnitude,RightArm.Size.z)
  65. prt.CFrame=CFrame.new((Origin+(HitPoint-Origin)*0.5),HitPoint)*CFrame.Angles(math.rad(90),0,0)
  66. for i = 0,1,.1 do
  67. prt.Transparency=i
  68. Render:wait()
  69. end
  70. prt:Destroy()
  71. end
  72. end
  73. RayCast((RightArm.CFrame*CFrame.new(0,-RightArm.Size.y/2,0)).p,Mouse.Hit.p,Character)
  74. end)
  75. table.insert(WhenYouStop,#WhenYouStop+1,Weld)
  76. RayPowers=true
  77. while RayPowers do
  78. Weld.C0=Torso.CFrame:inverse()*CFrame.new((Torso.CFrame*CFrame.new(Torso.Size.x/2+RightArm.Size.x/2,Torso.Size.y/2-RightArm.Size.z/2,0)).p,Mouse.Hit.p)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0,Torso.Size.z/2-RightArm.Size.y/2,0)
  79. Render:wait()
  80. end
  81. end
  82. end
  83. local function STOP()
  84. if RayPowers==true then
  85. if MouseConnection~=nil then
  86. MouseConnection:disconnect()
  87. end
  88. local Weld=LeftShoulder:clone()
  89. Weld.Parent=Character
  90. Weld.Part0=Torso
  91. Weld.Part1=RightArm
  92. for i,v in pairs(WhenYouStop) do
  93. if v then
  94. v:Destroy()
  95. end
  96. end
  97. RayPowers=false
  98. end
  99. end
  100. local NewConnection;NewConnection=Mouse.KeyDown:connect(function(key)
  101. if Character==nil or Character.Parent==nil then
  102. NewConnection:disconnect()
  103. return
  104. end
  105. if string.lower(key)=="r" then
  106. if RayPowers==true then
  107. pcall(STOP)
  108. else
  109. pcall(START)
  110. end
  111. end
  112. end)
  113. table.insert(MouseConnections,#MouseConnections+1,NewConnection)
  114. end
  115. pcall(BEGIN,Player.Character)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement