Hello! I was wondering how I can fix the issue where, when I apply linear velocity to the HumanoidRootPart, the character just gets stuck ragdolled in the air
Module script of ragdoll
function module.TimedRagdoll(char : Model, sec : number)
local humanoid = char:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
local ragdolled = char:FindFirstChild("ragdolled")
if not ragdolled then
ragdolled = Instance.new("BoolValue")
ragdolled.Name = "ragdolled"
ragdolled.Parent = char
end
ragdolled.Value = true
if not remote then return end
local plr = game.Players:GetPlayerFromCharacter(char)
remote:FireClient(plr, "Make", sec)
if humanoid:GetState() ~= Enum.HumanoidStateType.Physics then
for index, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
if joint.Name == "Root" then
socket:Destroy()
local hinge = Instance.new("HingeConstraint")
hinge.Parent = joint.Parent
hinge.Attachment0 = a1
hinge.Attachment1 = a2
hinge.LimitsEnabled = true
end
if joint.Name == "Neck" then
socket:Destroy()
local hinge = Instance.new("HingeConstraint")
hinge.Parent = joint.Parent
hinge.Attachment0 = a1
hinge.Attachment1 = a2
hinge.LimitsEnabled = true
end
joint.Enabled = false
end
end
task.wait(sec)
local plr = game.Players:GetPlayerFromCharacter(char)
if plr then
remote:FireClient(plr, "Destroy", sec)
end
for index, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = joint.Parent:FindFirstChild("BallSocketConstraint") or joint.Parent:FindFirstChild("HingeConstraint")
local a1 = joint.Part0:FindFirstChild("Attachment")
local a2 = joint.Part1:FindFirstChild("Attachment")
if socket then socket:Destroy() end
if a1 then a1:Destroy() end
if a2 then a2:Destroy() end
joint.Enabled = true
end
end
end
if ragdolled and ragdolled.Parent then
ragdolled:Destroy()
end
end
How I apply linear velocity
task.spawn(function()
local attachment = Instance.new("Attachment", enemyHRP)
local LV = Instance.new("LinearVelocity", attachment)
LV.MaxForce = math.huge
LV.Attachment0 = attachment
if combo == 3 then
if enemyPlayer then
Ragdoll.TimedRagdoll(enemyChar, 3)
end
if enemyChar then
Ragdoll.NpcRagdoll(enemyChar, 3)
end
LV.VectorVelocity = player.Character.HumanoidRootPart.CFrame.LookVector * 6
debris:AddItem(LV, 0.6)
debris:AddItem(attachment, 0.6)
else
LV.VectorVelocity = player.Character.HumanoidRootPart.CFrame.LookVector * 5
debris:AddItem(LV, 0.1)
debris:AddItem(attachment, 0.1)
end
end)