Advertisement
madman24

roblox grapple hook

Jul 7th, 2012
2,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.05 KB | None | 0 0
  1. Me = game.Players.djface203
  2.  
  3. Char = Me.Character
  4.  
  5. Name = "xSGrapple"
  6.  
  7. ToolName = "Grapple"
  8.  
  9. Hold = false
  10.  
  11. ButtonDown = false
  12.  
  13. NeckO = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  14.  
  15.  
  16.  
  17.  
  18.  
  19. function Prop(part, parent, collide, tran, ref, x, y, z, color, anchor, form)
  20.  
  21. part.Parent = parent
  22.  
  23. part.formFactor = form
  24.  
  25. part.CanCollide = collide
  26.  
  27. part.Transparency = tran
  28.  
  29. part.Reflectance = ref
  30.  
  31. part.Size = Vector3.new(x,y,z)
  32.  
  33. part.BrickColor = BrickColor.new(color)
  34.  
  35. part.TopSurface = 0
  36.  
  37. part.BottomSurface = 0
  38.  
  39. part.Anchored = anchor
  40.  
  41. part.Locked = true
  42.  
  43. part:BreakJoints()
  44.  
  45. end
  46.  
  47.  
  48.  
  49. function Weld(w, p, p1, a, b, c, x, y, z)
  50.  
  51. w.Parent = p
  52.  
  53. w.Part0 = p
  54.  
  55. w.Part1 = p1
  56.  
  57. w.C1 = CFrame.fromEulerAnglesXYZ(a,b,c) * CFrame.new(x,y,z)
  58.  
  59. end
  60.  
  61.  
  62.  
  63. function GetCF(pos1, pos2)
  64.  
  65. local pos4 = Vector3.new(pos2.X, pos1.Y, pos2.Z)
  66.  
  67. return CFrame.new(pos1, pos4)
  68.  
  69. end
  70.  
  71.  
  72.  
  73. function SetWeld(rw, R0, TO, mouse)
  74.  
  75. local offset = (TO.Position.Y - mouse.Hit.p.Y)/60
  76.  
  77. local mag = (TO.Position - mouse.Hit.p).magnitude/80
  78.  
  79. offset = offset/mag
  80.  
  81.  
  82.  
  83. TO.Neck.C0 = NeckO * CFrame.Angles(offset, 0, 0)
  84.  
  85.  
  86.  
  87. rw.C0 = R0 * CFrame.Angles(-offset, 0, 0)
  88.  
  89. end
  90.  
  91.  
  92.  
  93. Rarm = Char:findFirstChild("Right Arm")
  94.  
  95. Larm = Char:findFirstChild("Left Arm")
  96.  
  97. Torso = Char:findFirstChild("Torso")
  98.  
  99. Hum = Char:findFirstChild("Humanoid")
  100.  
  101.  
  102.  
  103. BG = Instance.new("BodyGyro")
  104.  
  105. BG.P = 10000
  106.  
  107. BG.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  108.  
  109.  
  110.  
  111. for i,v in pairs(Char:children()) do
  112.  
  113. if v.Name == Name then v:remove() end
  114.  
  115. end
  116.  
  117.  
  118.  
  119. Mod = Instance.new("Model")
  120.  
  121. Mod.Name = Name
  122.  
  123.  
  124.  
  125. Trail = Instance.new("Part")
  126.  
  127. Prop( Trail, nil, false, 0, 0, 0.3, 1, 0.3, "Reddish brown", false, "Custom" )
  128.  
  129. TrailMesh = Instance.new("CylinderMesh",Trail)
  130.  
  131.  
  132.  
  133. Main = Instance.new("Part")
  134.  
  135. Prop( Main, Mod, false, 0, 0, 0.6, 1.4, 0.6, "Dark green", false, "Custom" )
  136.  
  137. Instance.new("SpecialMesh",Main).MeshType = "Sphere"
  138.  
  139.  
  140.  
  141. TorsoHold = Instance.new("Weld")
  142.  
  143. Weld( TorsoHold, Torso, Main, math.pi*1.2, 0, 0, -1.1, 0.7, 0.3 )
  144.  
  145.  
  146.  
  147. Neck = Instance.new("Part")
  148.  
  149. Prop( Neck, Mod, false, 0, 0.1, 0.4, 1, 0.4, "Medium grey", false, "Custom" )
  150.  
  151. Instance.new("CylinderMesh",Neck)
  152.  
  153.  
  154.  
  155. NeckWeld = Instance.new("Weld")
  156.  
  157. Weld( NeckWeld, Main, Neck, 0, 0, 0, 0, -0.8, 0 )
  158.  
  159.  
  160.  
  161. for i = -60, 180, 20 do
  162.  
  163. local Hook = Instance.new("Part")
  164.  
  165. Prop( Hook, Mod, false, 0, 0.1, 0.3, 0.3, 0.3, "Medium grey", false, "Custom" )
  166.  
  167. Instance.new("CylinderMesh",Hook)
  168.  
  169.  
  170.  
  171. local HookW = Instance.new("Weld")
  172.  
  173. HookW.C0 = CFrame.new(-0.1, 1, 0) * CFrame.Angles(math.rad(i) - math.pi/1.7,0,0)
  174.  
  175. Weld( HookW, Neck, Hook, 0, 0, 0, 0, 0, -0.7 )
  176.  
  177. end
  178.  
  179.  
  180.  
  181. Hb = Instance.new("Part")
  182.  
  183. Prop( Hb, Mod, false, 1, 0, 0.1, 0.1, 0.1, "Bright red", false, "Custom" )
  184.  
  185. Hbw = Instance.new("Weld")
  186.  
  187. Weld( Hbw, Rarm, Hb, 0, 0, 0, 0, 1, 0)
  188.  
  189.  
  190.  
  191. HW = Instance.new("Weld")
  192.  
  193. Weld( HW, Hb, nil, -math.pi/2 - 0.7, 0, 0, 0, 0, 0)
  194.  
  195.  
  196.  
  197. Rb = Instance.new("Part")
  198.  
  199. Prop( Rb, Mod, false, 1, 0, 0.1, 0.1, 0.1, "Bright red", false, "Custom" )
  200.  
  201. Rh = Instance.new("Weld")
  202.  
  203. Weld( Rh, Torso, Rb, 0, 0, 0, -1.5, -0.5, 0)
  204.  
  205.  
  206.  
  207. Lb = Instance.new("Part")
  208.  
  209. Prop( Lb, Mod, false, 1, 0, 0.1, 0.1, 0.1, "Bright red", false, "Custom" )
  210.  
  211. Lh = Instance.new("Weld")
  212.  
  213. Weld( Lh, Torso, Lb, 0, 0, 0, 1.5, -0.5, 0)
  214.  
  215.  
  216.  
  217. RW = Instance.new("Weld")
  218.  
  219. Weld(RW,Rb,nil,0,0,0,0,0.5,0)
  220.  
  221.  
  222.  
  223. LW = Instance.new("Weld")
  224.  
  225. Weld(LW,Lb,nil,0,0,0,0,0.5,0)
  226.  
  227.  
  228.  
  229. RightBattle = nil
  230.  
  231. LeftBattle = nil
  232.  
  233. WepBattle = nil
  234.  
  235.  
  236.  
  237. Mod.Parent = Char
  238.  
  239.  
  240.  
  241. if script.Parent.className ~= "HopperBin" then
  242.  
  243. Hop = Instance.new("HopperBin")
  244.  
  245. Hop.Name = ToolName
  246.  
  247. Hop.Parent = Me.Backpack
  248.  
  249. script.Parent = Hop
  250.  
  251. end
  252.  
  253.  
  254.  
  255. bin = script.Parent
  256.  
  257.  
  258.  
  259. function HoldArm()
  260.  
  261. RW.Part1 = Rarm
  262.  
  263. LW.Part1 = Larm
  264.  
  265. TorsoHold.Part1 = nil
  266.  
  267. HW.Part1 = Main
  268.  
  269. end
  270.  
  271.  
  272.  
  273. function HoldTorso()
  274.  
  275. RW.Part1 = nil
  276.  
  277. LW.Part1 = nil
  278.  
  279. TorsoHold.Part1 = Main
  280.  
  281. HW.Part1 = nil
  282.  
  283. end
  284.  
  285.  
  286.  
  287. function Normalize()
  288.  
  289. RW.C0 = RightBattle
  290.  
  291. LW.C0 = LeftBattle
  292.  
  293. HW.C0 = WepBattle
  294.  
  295. Torso.Neck.C0 = NeckO
  296.  
  297. end
  298.  
  299.  
  300.  
  301. function SelectMotion()
  302.  
  303. HoldArm()
  304.  
  305. for i = 0, 40, 5 do
  306.  
  307. RW.C0 = CFrame.Angles(math.rad(i), 0, 0)
  308.  
  309. HW.C0 = CFrame.Angles(math.rad(i*4), 0, 0)
  310.  
  311. wait()
  312.  
  313. end
  314.  
  315. if RightBattle == nil then
  316.  
  317. RightBattle = RW.C0
  318.  
  319. WepBattle = HW.C0
  320.  
  321. LeftBattle = LW.C0
  322.  
  323. end
  324.  
  325. Normalize()
  326.  
  327. end
  328.  
  329.  
  330.  
  331. function DeselMotion()
  332.  
  333. HoldTorso()
  334.  
  335. end
  336.  
  337.  
  338.  
  339. function Throw(Mouse)
  340.  
  341. Hold = true
  342.  
  343. for i = 0, 120, 15 do
  344.  
  345. RW.C0 = RightBattle * CFrame.Angles(math.rad(i), 0, 0)
  346.  
  347. wait()
  348.  
  349. end
  350.  
  351. local co = RW.C0
  352.  
  353. BG.Parent = Torso
  354.  
  355. Mouse.Button1Up:connect(function()
  356.  
  357. Hold = false
  358.  
  359. BG.Parent = nil
  360.  
  361. end)
  362.  
  363. while Hold do
  364.  
  365. BG.cframe = GetCF(Torso.Position, Mouse.Hit.p)
  366.  
  367. SetWeld(RW, co, Torso, Mouse)
  368.  
  369. wait()
  370.  
  371. end
  372.  
  373. local Wn = RW.C0
  374.  
  375. for i = 0, -60, -20 do
  376.  
  377. RW.C0 = Wn * CFrame.Angles(math.rad(i), 0, 0)
  378.  
  379. wait()
  380.  
  381. end
  382.  
  383. Wn = RW.C0
  384.  
  385. HW.Part1 = nil
  386.  
  387. local BF = Instance.new("BodyForce",Main)
  388.  
  389. BF.force = Vector3.new(0,70,0)
  390.  
  391. local Mag = (Torso.Position - Mouse.Hit.p).magnitude
  392.  
  393. if Mag > 100 then Mag = 100 end
  394.  
  395. local Lol = CFrame.new(Torso.Position, Mouse.Hit.p) * CFrame.Angles(math.pi/8,0,0) * CFrame.new(0,0,-Mag/3)
  396.  
  397. Main.CanCollide = true
  398.  
  399. local BP = Instance.new("BodyPosition",Main)
  400.  
  401. BP.position = Lol.p
  402.  
  403. BP.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  404.  
  405. BP.P = 7000
  406.  
  407. wait()
  408.  
  409. BP:remove()
  410.  
  411. Trail.Parent = Mod
  412.  
  413. local touched = nil
  414.  
  415. Main.Touched:connect(function(h)
  416.  
  417. if h.CanCollide and h:GetMass() > 30 and touched == nil then
  418.  
  419. touched = h
  420.  
  421. end
  422.  
  423. end)
  424.  
  425. repeat
  426.  
  427. local ma = (Torso.Position - Main.Position).magnitude
  428.  
  429. TrailMesh.Scale = Vector3.new(1,ma,1)
  430.  
  431. Trail.CFrame = CFrame.new(Torso.Position, Main.Position) * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,-ma/2,0)
  432.  
  433. wait()
  434.  
  435. until touched ~= nil
  436.  
  437. local bpz = Instance.new("BodyPosition",Main)
  438.  
  439. bpz.P = 15000
  440.  
  441. bpz.position = Main.Position
  442.  
  443. bpz.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  444.  
  445. local bgz = Instance.new("BodyGyro",Main)
  446.  
  447. bgz.P = 5000
  448.  
  449. bgz.cframe = CFrame.new(Main.Position, Main.CFrame * CFrame.new(0,0,-2).p)
  450.  
  451. bgz.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  452.  
  453. for i = 0, 60, 10 do
  454.  
  455. RW.C0 = Wn * CFrame.Angles(math.rad(-i), 0, math.rad(-i/1.5)) * CFrame.new(0,math.rad(-i/1.5),0)
  456.  
  457. LW.C0 = LeftBattle * CFrame.Angles(math.rad(i*1.2), 0, math.rad(i/1.5)) * CFrame.new(0,math.rad(-i),0)
  458.  
  459. wait()
  460.  
  461. end
  462.  
  463. local bpp = Instance.new("BodyPosition",Torso)
  464.  
  465. bpp.P = 11000
  466.  
  467. bpp.position = Main.Position
  468.  
  469. bpp.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  470.  
  471. repeat wait() until (Torso.Position - Main.Position).magnitude < 15
  472.  
  473. bpz:remove()
  474.  
  475. bgz:remove()
  476.  
  477. bpp:remove()
  478.  
  479. Normalize()
  480.  
  481. Trail.Parent = nil
  482.  
  483. end
  484.  
  485.  
  486.  
  487. function Select(mouse)
  488.  
  489. SelectMotion()
  490.  
  491. mouse.Button1Down:connect(function() Throw(mouse) end)
  492.  
  493. end
  494.  
  495.  
  496.  
  497. function Desel()
  498.  
  499. DeselMotion()
  500.  
  501. end
  502.  
  503.  
  504.  
  505. bin.Selected:connect(Select)
  506.  
  507. bin.Deselected:connect(Desel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement