Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. local grappling = false
  2. local createdInstances
  3. local oldHipHeight
  4. local oldVel
  5.  
  6. local function SetHipHeight(num)
  7. local hum = plr.Character.Humanoid
  8. oldHipHeight = hum.HipHeight
  9. hum.HipHeight = num
  10. end
  11.  
  12. local function Stop()
  13. grappling = false
  14. rs.RemoteEvent:FireServer("GrappleFinished")
  15. table.foreach(createdInstances,function(_,v) v:Destroy() end)
  16. SetHipHeight(oldHipHeight)
  17. plr.Character.PrimaryPart.Velocity = Vector3.new(0,0,0)
  18. end
  19.  
  20. local function CreateInstances(att1,pos)
  21. local att0 = Instance.new("Attachment")
  22. local ball = script.Ball:Clone()
  23. ball.Position = pos
  24. local ap = script.AlignPosition:Clone()
  25. ap.Attachment0 = att0
  26. ap.Attachment1 = att1
  27. ball.Parent = plr.Character
  28. att0.Parent = plr.Character.PrimaryPart
  29. ap.Parent = plr.Character
  30. createdInstances = {att0, ap, ball = ball}
  31. end
  32.  
  33. local function CheckIfStuck(newVel)
  34. if newVel:isClose(oldVel,0.001) then
  35. Stop()
  36. return
  37. end
  38. self.oldVel = newVel
  39. end
  40.  
  41. game:GetService("UserInputService").InputBegan:Connect(function(i,g)
  42. if i.KeyCode == Enum.KeyCode.F and not g then
  43. local mouseh = mouse.Hit
  44. local att1, p = rs.RemoteFunction:InvokeServer("Grappled",mouseh)
  45. if att1 and p then
  46. grappling = true
  47. SetHipHeight(0)
  48. CreateInstances(att1,p)
  49. createdInstances.ball.Touched:Connect(function(h)
  50. if game.Players:GetPlayerFromCharacter(h.Parent) == plr then
  51. Stop()
  52. end
  53. end)
  54. oldVel = plr.Character.PrimaryPart.Velocity
  55. while grappling and game:GetService("RunService").Heartbeat:Wait() do
  56. grapple:CheckIfStuck(plr.Character.PrimaryPart.Velocity)
  57. end
  58. end
  59. end
  60. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement