HowToRoblox

ParachuteHandler

Jan 12th, 2021 (edited)
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. local char = plr.Character or plr.CharacterAdded:Wait()
  3.  
  4.  
  5. local tool = script.Parent
  6.  
  7.  
  8. local anim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("ParachuteAnim"))
  9.  
  10.  
  11. local bf
  12.  
  13.  
  14. tool.Equipped:Connect(function()
  15.  
  16.     game.ReplicatedStorage.ConnectM6D:FireServer(tool.BodyAttach)
  17.  
  18.     char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
  19.     char.UpperTorso.ToolGrip.Part1 = tool.BodyAttach
  20.  
  21.  
  22.     anim:Play()
  23. end)
  24.  
  25.  
  26. tool.Unequipped:Connect(function()
  27.  
  28.     game.ReplicatedStorage.DisconnectM6D:FireServer()
  29.  
  30.     anim:Stop()
  31.    
  32.     if bf then bf:Destroy() end
  33. end)
  34.  
  35.  
  36.  
  37. char:WaitForChild("Humanoid").StateChanged:Connect(function(oldState, newState)
  38.    
  39.     if script.Parent.Parent ~= char then return end
  40.    
  41.    
  42.     if newState == Enum.HumanoidStateType.Freefall and oldState == Enum.HumanoidStateType.Jumping then
  43.        
  44.         if bf then bf:Destroy() end
  45.        
  46.        
  47.         wait(0.3)
  48.        
  49.         bf = Instance.new("BodyForce")
  50.         bf.Force = Vector3.new(0, workspace.Gravity * 10, 0)
  51.        
  52.         bf.Parent = char.HumanoidRootPart
  53.        
  54.        
  55.     elseif newState == Enum.HumanoidStateType.Landed and bf then
  56.         bf:Destroy()
  57.     end
  58. end)
Add Comment
Please, Sign In to add comment