-
I have a ragdoll script that launches the player after touching a part
-
The player does not get unragdolled after the amount of time, it never goes beyond the second task.wait
-
I have tried using a coroutine, still has the same problem of the second task.wait() not passing through. I also have tried commenting out the Torso velocity, removing direction and strength variables, and doing both and it still doesn’t work
local ragdoll = {}
function ragdoll.doRagdoll(ragTime) -- This is the one that works
if (notRagdolled) then
notRagdolled = false
for _, motor6d in ipairs(script.Parent:GetDescendants()) do
if motor6d:IsA("Motor6D") then
motor6d.Enabled = false
end
end
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
headBodyJoint.Enabled = true
leftABodyJoint.Enabled = true
rightABodyJoint.Enabled = true
leftLBodyJoint.Enabled = true
rightLBodyJoint.Enabled = true
script.Parent.HumanoidRootPart.Anchored = true
print("Start2")
task.wait(1)
print("Can do 1")
task.wait(ragTime)
notRagdolled = true
script.Parent:FindFirstChild("Torso"):SetNetworkOwner(player)
print("End")
script.Parent.HumanoidRootPart:PivotTo(script.Parent.Torso.CFrame)
script.Parent.HumanoidRootPart.Position = Vector3.new(script.Parent.HumanoidRootPart.Position.X,script.Parent.HumanoidRootPart.Position.Y +0.5,script.Parent.HumanoidRootPart.Position.Z)
script.Parent.HumanoidRootPart.Anchored = false
script.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero
script.Parent.HumanoidRootPart:SetNetworkOwner(nil)
script.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero
script.Parent.HumanoidRootPart:SetNetworkOwner(player)
for _, motor6d in ipairs(script.Parent:GetDescendants()) do
if motor6d:IsA("Motor6D") then
motor6d.Enabled = true
end
end
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
headBodyJoint.Enabled = false
leftABodyJoint.Enabled = false
rightABodyJoint.Enabled = false
leftLBodyJoint.Enabled = false
rightLBodyJoint.Enabled = false
end
end
function ragdoll.launch(ragTime,direction, strength) -- This is the one that doesn't work
print(ragTime)
if (notRagdolled) then
notRagdolled = false
for _, motor6d in ipairs(script.Parent:GetDescendants()) do
if motor6d:IsA("Motor6D") then
motor6d.Enabled = false
end
end
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
headBodyJoint.Enabled = true
leftABodyJoint.Enabled = true
rightABodyJoint.Enabled = true
leftLBodyJoint.Enabled = true
rightLBodyJoint.Enabled = true
script.Parent.HumanoidRootPart.Anchored = true
task.wait()
waitTime = ragTime
local torso = script.Parent:FindFirstChild("Torso")
if torso:IsA("Part") then
torso:SetNetworkOwner(nil)
torso.AssemblyLinearVelocity = (direction.Unit * strength)
end
print("Start2")
task.wait(1)
print("Can do 1")
task.wait(ragTime)
print("End")
notRagdolled = true
script.Parent:FindFirstChild("Torso"):SetNetworkOwner(player)
script.Parent.HumanoidRootPart:PivotTo(script.Parent.Torso.CFrame)
script.Parent.HumanoidRootPart.Position = Vector3.new(script.Parent.HumanoidRootPart.Position.X,script.Parent.HumanoidRootPart.Position.Y +0.5,script.Parent.HumanoidRootPart.Position.Z)
script.Parent.HumanoidRootPart.Anchored = false
script.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero
script.Parent.HumanoidRootPart:SetNetworkOwner(nil)
script.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero
script.Parent.HumanoidRootPart:SetNetworkOwner(player)
for _, motor6d in ipairs(script.Parent:GetDescendants()) do
if motor6d:IsA("Motor6D") then
motor6d.Enabled = true
end
end
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
headBodyJoint.Enabled = false
leftABodyJoint.Enabled = false
rightABodyJoint.Enabled = false
leftLBodyJoint.Enabled = false
rightLBodyJoint.Enabled = false
end
end
return ragdoll