Advertisement
Guest User

Grapple Hook Script

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