cr8brooo

Hand Launcher

Aug 13th, 2020
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local next=next
  2. local crosshairimg="http://www.roblox.com/asset?id=20457765"
  3. game:service("ContentProvider"):Preload(crosshairimg)
  4. local ready=false
  5.  
  6. local event
  7. local p=game.Players.LocalPlayer
  8. function run(pc)
  9. if event then event:disconnect() end
  10. wait(0.25)
  11. local tor=pc and pc:findFirstChild("Torso")
  12. local rs=tor and tor:findFirstChild("Right Shoulder")
  13. local ra=pc and pc:findFirstChild("Right Arm")
  14. local rac=ra:Clone()
  15. if rs then
  16. rs:Destroy()
  17. end
  18. local j=Instance.new("Weld",tor)
  19. j.Name="Aim"
  20. j.Part0=tor
  21. j.Part1=ra
  22. j.C0=CFrame.new(1.5,0.5,0)
  23. j.C1=CFrame.new(0,0.5,0, 1,0,0, 0,0,1, 0,-1,0)
  24. local s=Instance.new("HopperBin",p.Backpack)
  25. s.Name="Limb Launcher"
  26. local g=Instance.new("ScreenGui",p.PlayerGui)
  27. g.Name="Crosshair no target"
  28. local img1=Instance.new("ImageLabel",g)
  29. img1.Name="IMG"
  30. img1.Size=UDim2.new(0,210,0,210)
  31. img1.Position=UDim2.new(0,0,0,0)
  32. img1.BackgroundTransparency=1
  33. img1.Visible=false
  34. img1.Image=crosshairimg
  35. local ch=Instance.new("BillboardGui",p.PlayerGui)
  36. ch.Name="Crosshair on target"
  37. ch.Size=UDim2.new(0,210,0,210)
  38. ch.AlwaysOnTop=true
  39. ch.Enabled=false
  40. local img2=Instance.new("ImageLabel",ch)
  41. img2.Name="IMG"
  42. img2.Size=UDim2.new(1,0,1,0)
  43. img2.BackgroundTransparency=1
  44. img2.Image=crosshairimg
  45. local status=Instance.new("TextLabel",g)
  46. status.Name="Status"
  47. status.Size=UDim2.new(0,100,0,25)
  48. status.Position=UDim2.new(0,110,1,-85)
  49. status.Text=""
  50. status.FontSize=Enum.FontSize.Size14
  51. status.BackgroundColor=BrickColor.new("Really black")
  52. status.TextColor=BrickColor.new("Institutional white")
  53. status.BorderSizePixel=0
  54.  
  55. local shot=false
  56. event=s.Selected:connect(function(m)
  57. local ccf
  58. local target
  59. local ftarg
  60. local hadtarget=false
  61. local unaim=false
  62. s.Parent=nil
  63. img1.Position=UDim2.new(0,m.X-105,0,m.Y-105)
  64. img1.Visible=true
  65. local aim=function()
  66. if not shot then
  67. target=nil
  68. local r=m.UnitRay
  69. local len=math.huge
  70. for _,o in next,workspace:GetChildren() do
  71. local fh=false
  72. for _,hum in next,o:GetChildren() do
  73. if hum.ClassName=="Humanoid" then
  74. fh=true
  75. break
  76. end
  77. end
  78. if o~=pc and fh then
  79. local h=o:findFirstChild("Head") or o:findFirstChild("Torso")
  80. if h and h.ClassName=="Part" then
  81. local cp=r:ClosestPoint(h.Position)
  82. local d=(h.Position-cp).magnitude/(cp-r.Origin).magnitude
  83. if d<=0.125 and d<=len then
  84. target=h
  85. len=d
  86. end
  87. end
  88. end
  89. end
  90. if target then
  91. local pos=tor.CFrame:pointToObjectSpace(target.Position)
  92. j.C0=CFrame.new(Vector3.new(1.5,0.5,0),pos)
  93. if target~=hadtarget then
  94. --print("Target acquired: ",target)
  95. hadtarget=target
  96. img1.Visible=false
  97. ch.Adornee=target
  98. ch.Enabled=true
  99. end
  100. status.Text="["..math.floor(pos.magnitude).."]"
  101. elseif not target then
  102. local pos=tor.CFrame:pointToObjectSpace((m.hit or tor.CFrame*CFrame.new(1.5,0.5,1)).p)
  103. j.C0=CFrame.new(Vector3.new(1.5,0.5,0),pos)
  104. img1.Position=UDim2.new(0,m.X-105,0,m.Y-105)
  105. if hadtarget then
  106. --print("Target lost")
  107. hadtarget=false
  108. ch.Enabled=false
  109. ch.Adornee=nil
  110. img1.Visible=true
  111. end
  112. status.Text=math.floor(pos.magnitude)
  113. end
  114. end
  115. end
  116.  
  117. local ev1=m.Move:connect(function() unaim=aim() end)--move arm and check for nearby targets
  118. local ev2=m.Button1Down:connect(function()--shoot at target
  119. unaim=aim()--returns nothing, but makes the continuous aim skip so it doesn't use up CPU for nothing
  120. ccf=tor.CFrame*j.C0*(j.C1:inverse())
  121. ftarg=target
  122. shot=true
  123. end)
  124.  
  125. repeat
  126. local ora=ra
  127. repeat--continuous aim
  128. if unaim then
  129. aim()
  130. else
  131. unaim=true
  132. end
  133. wait()
  134. until shot
  135. j:Destroy()
  136. local cccf=ccf
  137. local ltarg=ftarg
  138. local explode=false
  139. local v=Instance.new("BodyVelocity",ora)
  140. local b=Instance.new("BodyGyro",ora)
  141. b.maxTorque=Vector3.new(1e7,1e7,1e7)
  142. local function point(vel,cf)
  143. local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz=cf:components()
  144. v.velocity=-Vector3.new(yx,yy,yz)*vel
  145. b.cframe=cf
  146. end
  147. local v=0
  148. coroutine.resume(coroutine.create(function()
  149. local last=ora.Position
  150. repeat
  151. v=v+0.2
  152. if ltarg then
  153. local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz=CFrame.new(Vector3.new(0,0,0),ltarg.Position-ora.Position):components()
  154. point(v,CFrame.new(0,0,0, xx,zx,-yx, 0,zy,yy, xz,zz,-yz))
  155. else
  156. point(v,cccf)
  157. end
  158. last=ora.Position
  159. wait()
  160. until explode or not (ora and ora.Parent==workspace)
  161. local exp=Instance.new("Explosion",workspace)
  162. exp.Position=last
  163. exp.BlastRadius=v/6
  164. if ltarg then
  165. for _,ff in next,ltarg.Parent:GetChildren() do
  166. local fie=ff.ClassName=="ForceField" and ff or ff:findFirstChild("ForceField")
  167. if fie then
  168. fie:Destroy()
  169. end
  170. end
  171. end
  172. end))
  173. ora.Name = "Vroom Vroom going to hit yo face!"
  174. coroutine.resume(coroutine.create(function()
  175. local f=Instance.new("Fire",ora)
  176. f.Name="Fiar"
  177. f.Size=0.49
  178. wait(1)
  179. ora.Touched:connect(function(h)
  180. if (h==ltarg or not (ltarg and workspace:IsAncestorOf(ltarg))) and not (pc and pc.Parent==workspace and h:IsDescendantOf(pc)) and not (h:findFirstChild("Fiar") and h.Fiar.Size==0.49) and h.Name ~= "Vroom Vroom going to hit yo face!" then
  181. explode=true
  182. ora:Destroy()
  183. end
  184. end)
  185. end))
  186. ora.Parent=workspace
  187. ra=rac:Clone()
  188. ra.Parent=pc
  189. j=Instance.new("Weld",tor)
  190. j.Name="Aim"
  191. j.Part0=tor
  192. j.Part1=ra
  193. j.C0=CFrame.new(1.5,0.5,0)
  194. j.C1=CFrame.new(0,0.5,0, 1,0,0, 0,0,1, 0,-1,0)
  195. shot=false
  196. until not (pc and pc.Parent==workspace or not (p and p.Parent==game.Players)) and not (ra and ra:IsDescendantOf(workspace))
  197. ev1:disconnect()
  198. ev2:disconnect()
  199. end)
  200. end
  201.  
  202. if p.Character then
  203. run(p.Character)
  204. end
Add Comment
Please, Sign In to add comment