I’m trying to make a skydiving system on roblox.But I’m facing a problem.When the skydiving animation plays, the parachute appears but it’s position is little far from the character.I don’t know where the problem is.Here is the script and a video footage of the problem:
video:
robloxapp-20201220-1837424.wmv (1.6 MB)
Script:
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://**********animation Id"
local anim = hum:LoadAnimation(animation)
local freefalling = false
function transparentChute()
chute = game.ReplicatedStorage.Chute:Clone()
chute.Parent = char
for _, v in pairs(chute:GetChildren()) do
v.Transparency = 1
end
end
transparentChute()
function openChute()
local chuteWeld = chute.Handle:WaitForChild("ChuteWeld")
if chuteWeld then
chuteWeld.Part1 = hrp
local chuteCFrame = chute.PrimaryPart.CFrame
chuteCFrame = hrp.CFrame * chuteCFrame:ToWorldSpace(hrp.CFrame)
local chuteComponents = chute:GetChildren()
for _, v in pairs(chuteComponents) do
if v.Transparency == 1 then
v.Transparency = 0
end
end
end
end
function freefall()
local currentState = hum:GetState()
if currentState == Enum.HumanoidStateType.Freefall then
local bodyVelocity = Instance.new("BodyVelocity", hrp)
bodyVelocity.Name = "Freefall"
bodyVelocity.MaxForce = Vector3.new(0, 100000, 0)
bodyVelocity.P = 1000000
bodyVelocity.Velocity = Vector3.new(0, -50, 0)
bodyVelocity.Parent = hrp
print("Successfull")
anim:Play()
if not freefalling then
freefalling = true
end
print(freefalling)
openChute()
end
end
hum.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Freefall then
wait(4)
if newState == Enum.HumanoidStateType.Freefall then
freefall()
end
elseif newState ~= Enum.HumanoidStateType.Freefall then
local check = hrp:FindFirstChild("Freefall")
if check and freefalling then
freefalling = false
print(freefalling)
anim:Stop()
check:Destroy()
end
end
end)```