Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. local remote = game:GetService("ReplicatedStorage").RemoteEvent
  3. local grapple = {}
  4.  
  5. function grapple.New()
  6.     local object = setmetatable({},{_index=grapple})
  7.     return object
  8. end
  9.  
  10. function grapple:Start(att1,pos)
  11.     self:SetHipHeight(0)
  12.     local att0 = Instance.new("Attachment")
  13.     local ap = Instance.new("AlignPosition")
  14.     local ball = Instance.new("Part")
  15.     ap.Attachment0 = att0
  16.     ap.Attachment1 = att1
  17.     ap.ReactionForceEnabled = true
  18.     ap.Responsiveness = 50
  19.     ap.MaxForce = 10000
  20.     ball.Shape = Enum.PartType.Ball
  21.     ball.Size = Vector3.new(5,5,5)
  22.     ball.Transparency = 1
  23.     ball.CanCollide = false
  24.     ball.Anchored = true
  25.     ball.Position = pos
  26.     self.CreatedInstances = {att0, ap, Ball = ball}
  27.     ball.Parent = plr.Character
  28.     att0.Parent = plr.Character.PrimaryPart
  29.     ap.Parent = plr.Character
  30. end
  31.  
  32. function grapple:SetHipHeight(num)
  33.     local hum = plr.Character:FindFirstChild("Humanoid")
  34.     if hum then
  35.         self.OldHipHeight = hum.HipHeight
  36.         hum.HipHeight = num
  37.     end
  38. end
  39.  
  40. function grapple:Stop()
  41.     for i,v in next, self.CreatedInstances do
  42.         v:Destroy()
  43.     end
  44.     self:SetHipHeight(self.OldHipHeight)
  45.     if plr.Character.PrimaryPart then
  46.         plr.Character.PrimaryPart.Velocity = Vector3.new(0,0,0)
  47.     end
  48.     remote:FireServer("GrappleFinished")
  49. end
  50.  
  51.  
  52. return grapple
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement