Problem with parachute system

Im making a skydiving system.But I could not make the bodyvelocity work in HumanoidRootPart’s lookvector direction. I made velocity work in the direction where camera is looking. But I want to make it work to move in HumanoidRootPart’s lookvector direction.I tried it.But It glitches.

Video:
robloxapp-20210107-1731579.wmv (1.6 MB)

The Script:


local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

--Camera--

local camera = workspace.CurrentCamera

--player's character components--

repeat wait() until Players.LocalPlayer.Character
local player = Players.LocalPlayer
local character = player.Character
local humanoidRootPart  = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")

--Parachute GUi--

local guiOfParachute = player.PlayerGui:FindFirstChild("Parachute")

--Booleans--

local canFreeFall = false
local freeFalling = false
local animPlaying = false
local isOnGround 

--Skydiving Animation--

local animation = Instance.new("Animation")
animation.AnimationId =  "rbxassetid://6107863733"
local anim = humanoid:LoadAnimation(animation)

--body Movers--

local bodyPos = Instance.new("BodyPosition")
bodyPos.MaxForce = Vector3.new()
bodyPos.D = 0
bodyPos.P = 100
bodyPos.Parent = humanoidRootPart


--Opening the Chute(Just a function waiting to be declared)--

function openChute()
    local chute = game.ReplicatedStorage.Chute:Clone()
	chute.Parent = character
	local motor6D = Instance.new("Motor6D",chute.Handle)
	motor6D.Part0 = humanoidRootPart
	motor6D.Part1 = chute.Handle
end

function freefallVelocity()
	
	RunService.RenderStepped:Connect(function()

		if freeFalling then

			bodyPos.MaxForce = Vector3.new(math.huge, 0, math.huge)


			bodyPos.Position = humanoidRootPart.Position +((humanoidRootPart.Position - camera.CFrame.Position).Unit * 3)



		else
			bodyPos.MaxForce = Vector3.new()

		end
	end)
end

--Functions--

function freefall()
	local currentState = humanoid:GetState()
	if currentState == Enum.HumanoidStateType.Freefall then
		if canFreeFall then
			canFreeFall = false
			if not animPlaying then
				anim:Play()
			end
			if not freeFalling then
				freeFalling = true
				
			end
		end
	end
end


humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Freefall then
		while true do
			wait()
			if humanoidRootPart.Velocity.y < -100 then
				canFreeFall = true
				if canFreeFall then
					freefall()
					freefallVelocity()
					guiOfParachute.Enabled = true
					guiOfParachute.ImageButton.MouseButton1Click:Connect(function()
						guiOfParachute.Enabled = false
						openChute()
					end)
					guiOfParachute.ImageButton.TouchTap:Connect(function()
						guiOfParachute.Enabled = false
						openChute()
					end)
					break
				end
			end
		end
		
	elseif newState == Enum.HumanoidStateType.Landed then
		guiOfParachute.Enabled = false
		anim:Stop()
		canFreeFall = true
		freeFalling = false
		local chute = character:WaitForChild("Chute")
		if chute then
			chute:Destroy()
		end
		
	end
end)





First, the video isn’t in the correct format.

Second, I don’t think thats the whole script. If you want us to help you, Please provide the whole script.

1 Like

I provided the whole script.Now , you can see the whole script. :slight_smile:

1 Like