Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local plr = game.Players.LocalPlayer
  2. local grapple = {}
  3.  
  4. function grapple.New()
  5.     local object = setmetatable({},{_index=grapple})
  6.     return object
  7. end
  8.  
  9. function grapple:Start(att1,pos)
  10.     self:SetHipHeight(0)
  11.     local att0 = Instance.new("Attachment")
  12.     local ap = script.AlignPosition:Clone()
  13.     ap.Attachment0 = att0
  14.     ap.Attachment1 = att1
  15.     local ball = script.Ball:Clone()
  16.     ball.Position = pos
  17.     self.createdInstances = {att0, ap, ball = ball}
  18.     ball.Parent = plr.Character
  19.     att0.Parent = plr.Character.PrimaryPart
  20.     ap.Parent = plr.Character
  21. end
  22.  
  23. function grapple:SetHipHeight(num)
  24.     local hum = plr.Character:FindFirstChild("Humanoid")
  25.     if hum then
  26.         self.oldHipHeight = hum.HipHeight
  27.         hum.HipHeight = num
  28.     end
  29. end
  30.  
  31. function grapple:Stop()
  32.     for i,v in next, self.createdInstances do
  33.         v:Destroy()
  34.     end
  35.     self:SetHipHeight(self.oldHipHeight)
  36.     if plr.Character.PrimaryPart then
  37.         plr.Character.PrimaryPart.Velocity = Vector3.new(0,0,0)
  38.     end
  39.     game:GetService("ReplicatedStorage").RemoteEvent:FireServer("GrappleFinished")
  40. end
  41.  
  42.  
  43. return grapple
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement