Advertisement
HowToRoblox

SkydiveServer

Jan 21st, 2022
2,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local playerTrails = {}
  2.  
  3. local trailParts = {"LeftHand", "RightHand", "LeftFoot", "RightFoot"}
  4.  
  5.  
  6. game.ReplicatedStorage:WaitForChild("SkydiveRE").OnServerEvent:Connect(function(plr, skydiving)
  7.    
  8.     if skydiving == true then
  9.        
  10.         playerTrails[plr] = {}
  11.        
  12.         for i, partName in pairs(trailParts) do
  13.            
  14.             local trail = script.Trail:Clone()
  15.            
  16.             local bodyPart = plr.Character[partName]
  17.            
  18.             local atch0 = Instance.new("Attachment", bodyPart)
  19.             atch0.Position = Vector3.new(0.5, 0, 0)
  20.             local atch1 = Instance.new("Attachment", bodyPart)
  21.             atch1.Position = Vector3.new(-0.5, 0, 0)
  22.            
  23.             trail.Attachment0 = atch0
  24.             trail.Attachment1 = atch1
  25.             trail.Parent = bodyPart
  26.            
  27.             table.insert(playerTrails[plr], trail)
  28.             table.insert(playerTrails[plr], atch0)
  29.             table.insert(playerTrails[plr], atch1)
  30.         end
  31.        
  32.     elseif skydiving == false and playerTrails[plr] then
  33.        
  34.         for i, trail in pairs(playerTrails[plr]) do
  35.            
  36.             trail:Destroy()
  37.         end
  38.        
  39.        
  40.     elseif skydiving == "parachute" then
  41.        
  42.         local bv = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
  43.         bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  44.         bv.Velocity = Vector3.new(0, -100, 0)
  45.        
  46.        
  47.         local parachute = script.Parachute:Clone()
  48.         parachute.Parent = plr.Character.UpperTorso
  49.        
  50.         local weld = Instance.new("Weld", plr.Character.UpperTorso)
  51.  
  52.         weld.Part0 = plr.Character.UpperTorso
  53.         weld.Part1 = parachute.MainPart
  54.         weld.C1 = CFrame.new(0, 0, 0.5)
  55.        
  56.        
  57.     elseif skydiving == "landed" then
  58.        
  59.         for i, descendant in pairs(plr.Character:GetDescendants()) do
  60.            
  61.             if descendant:IsA("BodyVelocity") or descendant.Name == "Parachute" then
  62.                
  63.                 descendant:Destroy()
  64.             end
  65.         end
  66.     end
  67. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement