Ragdoll modular script not ending the ragdoll because a task.wait isn't being passed through

  1. I have a ragdoll script that launches the player after touching a part

  2. The player does not get unragdolled after the amount of time, the second task.wait() never ends

  3. I have tried using a coroutine, still has the same problem of the second task.wait() not passing through

function ragdoll.launch(ragTime,direction, strength)
	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)
		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

Screenshot 2025-04-03 171333

1 Like

I have tried commenting out the Torso velocity, but it still doesn’t work

If this helps, this doesn’t have the same problem

function ragdoll.doRagdoll(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
		
		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

Update: I have tried removing direction and strength from the modular script while having the linear velocity stuff be commented out, and I made the launch function the exact same as the doRagdoll function, still has the problem