Hello, fellow developers. I have two completely different parachute and skydiving scripts in StarterCharacterScripts that don’t work very well with each other. The main issue is that the parachute welded to the HumanoidRootPart is unable to be destroyed when the player hits the ground, perhaps because the skydive script makes the HumanoidStateType never able to become “Landed”. Other issues, like the player skydiving while also parachuting at the same time, are not as important, but still need to be worked on.
Here are my scripts (please take note that these scripts are based off of two different tutorials):
ParachuteHandler
local character = script.Parent
local player = game.Players.LocalPlayer
local humanoid = character:WaitForChild("Humanoid")
local IsFalling = false
local UserInputService = game:GetService("UserInputService")
local parachuteDeployed = false
humanoid.StateChanged:Connect(function(oldstate, newState)
if newState == Enum.HumanoidStateType.Freefall then
if IsFalling == false then
IsFalling = true
wait(0.5)
if IsFalling == true then
print("Press Space to Deploy Parachute")
end
end
elseif newState == Enum.HumanoidStateType.Landed then
if IsFalling == true then
IsFalling = false
print("Player is Not Falling")
if character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Chute") then
character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Chute"):Destroy()
character:FindFirstChild("HumanoidRootPart"):FindFirstChild("WeldConstraint"):Destroy()
character:FindFirstChild("HumanoidRootPart"):FindFirstChild("BodyVelocity"):Destroy()
parachuteDeployed = false
end
end
end
end)
UserInputService.InputBegan:Connect(function(input, gameproccessed)
if input.UserInputType == Enum.UserInputType.Keyboard and not gameproccessed then
if input.KeyCode == Enum.KeyCode.Space then
if IsFalling == true then
if parachuteDeployed == false then
parachuteDeployed = true
local chute = game.ReplicatedStorage:FindFirstChild("Chute"):Clone()
chute.Parent = character:FindFirstChild("HumanoidRootPart")
chute.CFrame = CFrame.new(character:FindFirstChild("HumanoidRootPart").Position)
local weld = Instance.new("WeldConstraint")
weld.Parent = character:FindFirstChild("HumanoidRootPart")
weld.Part0 = character:FindFirstChild("HumanoidRootPart")
weld.Part1 = chute
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = character:FindFirstChild("HumanoidRootPart")
BodyVelocity.Velocity = Vector3.new(0, -10, 0)
BodyVelocity.MaxForce = Vector3.new(0, 5500, 0)
end
end
end
end
end)
SkydiveHandler
wait()
local AtmosphericPressureInfluence = true
local EnableContrails = true
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
Player.CharacterAdded:Connect(function(Char)
Character = Char
Humanoid = Char:WaitForChild("Humanoid")
HumanoidRootPart = Char:WaitForChild("HumanoidRootPart")
end)
local Run = game:GetService("RunService")
local Camera = game.Workspace.CurrentCamera
local Gyro = Instance.new("BodyGyro",HumanoidRootPart)
Gyro.Name = "SkydiveGyro"
local IsFalling = Instance.new("BoolValue",HumanoidRootPart)
IsFalling.Name = "IsFalling"
IsFalling.Value = false
local MainAnimation
local ForwardAnimation
local RightAnimation
local LeftAnimation
local ContrailBodyPart1
local ContrailBodyPart2
local ContrailBodyPart3
local ContrailBodyPart4
local AttachmentPosition1 = Vector3.new(-0.3,0,0)
local AttachmentPosition2 = Vector3.new(0.3,0,0)
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
MainAnimation = script.MainAnimationR6.AnimationId
ForwardAnimation = script.ForwardAnimationR6.AnimationId
RightAnimation = script.RightAnimationR6.AnimationId
LeftAnimation = script.LeftAnimationR6.AnimationId
ContrailBodyPart1 = Character:WaitForChild("Left Arm")
ContrailBodyPart2 = Character:WaitForChild("Right Arm")
ContrailBodyPart3 = Character:WaitForChild("Left Leg")
ContrailBodyPart4 = Character:WaitForChild("Right Leg")
AttachmentPosition1 = Vector3.new(-0.3,-0.9,0)
AttachmentPosition2 = Vector3.new(0.3,-0.9,0)
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
MainAnimation = script.MainAnimationR15.AnimationId
ForwardAnimation = script.ForwardAnimationR15.AnimationId
RightAnimation = script.RightAnimationR15.AnimationId
LeftAnimation = script.LeftAnimationR15.AnimationId
ContrailBodyPart1 = Character:WaitForChild("LeftHand")
ContrailBodyPart2 = Character:WaitForChild("RightHand")
ContrailBodyPart3 = Character:WaitForChild("LeftFoot")
ContrailBodyPart4 = Character:WaitForChild("RightFoot")
AttachmentPosition1 = Vector3.new(-0.3,0,0)
AttachmentPosition2 = Vector3.new(0.3,0,0)
end
local Animation = Instance.new("Animation",Character)
Animation.AnimationId = MainAnimation
local FreeFallAnimation = Humanoid:LoadAnimation(Animation)
FreeFallAnimation.Priority = Enum.AnimationPriority.Core
local Animation2 = Instance.new("Animation",Character)
Animation2.AnimationId = ForwardAnimation
local FreeFallAnimationForward = Humanoid:LoadAnimation(Animation2)
local Animation3 = Instance.new("Animation",Character)
Animation3.AnimationId = LeftAnimation
local FreeFallAnimationLeft = Humanoid:LoadAnimation(Animation3)
FreeFallAnimationLeft.Priority = Enum.AnimationPriority.Idle
local Animation4 = Instance.new("Animation",Character)
Animation4.AnimationId = RightAnimation
local FreeFallAnimationRight = Humanoid:LoadAnimation(Animation4)
FreeFallAnimationRight.Priority = Enum.AnimationPriority.Idle
local InitialGravity = workspace.Gravity
local DragRatio = 0.997
local DragDiminish = 0
local Drag = DragRatio
local MinimumSpeed = -91.1344415
local GlideLR = 0
local GlideFB = 0
local TiltLR = 0
local TiltFB = 0
local MinimumAltitude = math.huge
if EnableContrails == true then
local Attachment1A = Instance.new("Attachment",ContrailBodyPart1)
Attachment1A.Position = AttachmentPosition1
local Attachment2A = Instance.new("Attachment",ContrailBodyPart1)
Attachment2A.Position = AttachmentPosition2
ContrailsA = Instance.new("Trail",ContrailBodyPart1)
ContrailsA.Attachment0 = Attachment1A
ContrailsA.Attachment1 = Attachment2A
ContrailsA.Texture = "rbxassetid://3517446796"
ContrailsA.LightInfluence = 1
ContrailsA.TextureLength = 1
ContrailsA.FaceCamera = true
ContrailsA.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(0.1,0.7),
NumberSequenceKeypoint.new(1,1)
}
local Attachment1B = Instance.new("Attachment",ContrailBodyPart2)
Attachment1B.Position = AttachmentPosition1
local Attachment2B = Instance.new("Attachment",ContrailBodyPart2)
Attachment2B.Position = AttachmentPosition2
ContrailsB = Instance.new("Trail",ContrailBodyPart2)
ContrailsB.Attachment0 = Attachment1B
ContrailsB.Attachment1 = Attachment2B
ContrailsB.Texture = "rbxassetid://3517446796"
ContrailsB.LightInfluence = 1
ContrailsB.TextureLength = 1
ContrailsB.FaceCamera = true
ContrailsB.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(0.1,0.7),
NumberSequenceKeypoint.new(1,1)
}
local Attachment1C = Instance.new("Attachment",ContrailBodyPart3)
Attachment1C.Position = AttachmentPosition1
local Attachment2C = Instance.new("Attachment",ContrailBodyPart3)
Attachment2C.Position = AttachmentPosition2
ContrailsC = Instance.new("Trail",ContrailBodyPart3)
ContrailsC.Attachment0 = Attachment1C
ContrailsC.Attachment1 = Attachment2C
ContrailsC.Texture = "rbxassetid://3517446796"
ContrailsC.LightInfluence = 1
ContrailsC.TextureLength = 1
ContrailsC.FaceCamera = true
ContrailsC.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(0.1,0.7),
NumberSequenceKeypoint.new(1,1)
}
local Attachment1D = Instance.new("Attachment",ContrailBodyPart4)
Attachment1D.Position = AttachmentPosition1
local Attachment2D = Instance.new("Attachment",ContrailBodyPart4)
Attachment2D.Position = AttachmentPosition2
ContrailsD = Instance.new("Trail",ContrailBodyPart4)
ContrailsD.Attachment0 = Attachment1D
ContrailsD.Attachment1 = Attachment2D
ContrailsD.Texture = "rbxassetid://3517446796"
ContrailsD.LightInfluence = 1
ContrailsD.TextureLength = 1
ContrailsD.FaceCamera = true
ContrailsD.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(0.1,0.7),
NumberSequenceKeypoint.new(1,1)
}
end
Player:GetMouse().KeyDown:Connect(function(Key)
if Key:byte() == 119 or Key:byte() == 17 then -- W
TiltFB = -1
GlideFB = 2
Drag = DragRatio*(0.997+DragDiminish)
if IsFalling.Value == true then
FreeFallAnimationForward:Play(0.25)
end
elseif Key:byte() == 97 or Key:byte() == 20 then -- A
TiltLR = 1
GlideLR = -1
if IsFalling.Value == true then
FreeFallAnimationLeft:Play(0.25)
end
elseif Key:byte() == 100 or Key:byte() == 19 then -- D
TiltLR = -1
GlideLR = 1
if IsFalling.Value == true then
FreeFallAnimationRight:Play(0.25)
end
elseif (Key:byte() == 97 and Key:byte() == 100) or (Key:byte() == 20 and Key:byte() == 19) then
TiltLR = 0
GlideLR = 0
FreeFallAnimationLeft:Stop()
FreeFallAnimationRight:Stop()
end
end)
Player:GetMouse().KeyUp:Connect(function(Key)
if Key:byte() == 119 or Key:byte() == 17 then -- W
TiltFB = 0
GlideFB = 0
Drag = DragRatio
FreeFallAnimationForward:Stop()
elseif (Key:byte() == 97 or Key:byte() == 20) or (Key:byte() == 100 or Key:byte() == 19) then -- A/D
TiltLR = 0
GlideLR = 0
FreeFallAnimationLeft:Stop()
FreeFallAnimationRight:Stop()
end
end)
IsFalling.Changed:Connect(function()
if IsFalling.Value == true then
FreeFallAnimation:Play(1)
else
FreeFallAnimation:Stop()
FreeFallAnimationForward:Stop()
FreeFallAnimationLeft:Stop()
FreeFallAnimationRight:Stop()
end
end)
Run.RenderStepped:Connect(function()
local Speed = HumanoidRootPart.Velocity.Y
local lookVector = Camera.CFrame.LookVector
if AtmosphericPressureInfluence == false then
DragDiminish = 0
MinimumAltitude = math.huge
else
DragDiminish = -((101.325*((((((86)-(0.00356*(HumanoidRootPart.Position.Y))+459.67)/(459.67+(86)))^5.256))))/101.325)*0.0015+0.0015
MinimumAltitude = (160000/(1+1.0001^HumanoidRootPart.Velocity.Y))-15000 -- This allows you to slow down safely if you entered the atmosphere with speeds up to 10,000 studs/s
end
if Speed <= MinimumSpeed and Humanoid.Sit == false and HumanoidRootPart.Position.Y <= MinimumAltitude and Humanoid.Health > 0 then
workspace.Gravity = 32.174 -- I used real gravity while making this script.
HumanoidRootPart.Velocity = HumanoidRootPart.Velocity*(Drag+DragDiminish)+Vector3.new(GlideLR,1,GlideLR)*HumanoidRootPart.CFrame.RightVector+Vector3.new(GlideFB,1,GlideFB)*HumanoidRootPart.CFrame.LookVector
Gyro.MaxTorque = Vector3.new(40000000,40000000,40000000)
Gyro.CFrame = CFrame.new(HumanoidRootPart.Position)*CFrame.Angles(0,math.atan2(-lookVector.X,-lookVector.Z),TiltLR/2)*CFrame.Angles(TiltFB,0,0)
Humanoid.PlatformStand = true
IsFalling.Value = true
Character.Animate.Disabled = true
ContrailsA.Enabled = true
ContrailsB.Enabled = true
ContrailsC.Enabled = true
ContrailsD.Enabled = true
else
workspace.Gravity = InitialGravity
Gyro.MaxTorque = Vector3.new(0,0,0)
Humanoid.PlatformStand = false
IsFalling.Value = false
Character.Animate.Disabled = false
ContrailsA.Enabled = false
ContrailsB.Enabled = false
ContrailsC.Enabled = false
ContrailsD.Enabled = false
end
end)
I have already tried disabling the SkydiveHandler when the player deploys the parachute, but then the player becomes stuck in the current skydive state and cannot move.
Thanks,
SpeakerDev
(I reuploaded this because the original topic didn’t get any replies. Thanks!)