Best way to make a body drag system?

howdy roblox devs! i’ve made a (extremely) messy ragdoll dragging script which is functional but very, very far from perfect. here’s what i mean:


as you can see the movement is very weird and just doesn’t feel smooth at all. does anyone have suggestions how to improve it? should i add animations? thanks!

client side code:

dragEvent.OnClientEvent:Connect(function(char)
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
			v.CanCollide = true
		end
	end
	
	local torso = char:WaitForChild("Torso")
	
	local pChar = player.Character
	local pRootPart = pChar:WaitForChild("HumanoidRootPart")
	local pTorso = pChar:WaitForChild("Torso")
	local pRightArm = pChar:WaitForChild("Right Arm")
	local pLeftArm = pChar:WaitForChild("Left Arm")
	local pRightGrip : Attachment = pRightArm:WaitForChild("RightGripAttachment")
	local pLeftGrip : Attachment = pLeftArm:WaitForChild("LeftGripAttachment")

	local npcRightGrip : Attachment = char:WaitForChild("Right Arm"):WaitForChild("RightGripAttachment")
	local npcLeftGrip : Attachment = char:WaitForChild("Left Arm"):WaitForChild("LeftGripAttachment")

	local rightDragSocket = Instance.new("BallSocketConstraint")
	local leftDragSocket = Instance.new("BallSocketConstraint")

	local rightShoulder : Motor6D = pTorso:FindFirstChild("Right Shoulder")
	local leftShoulder : Motor6D = pTorso:FindFirstChild("Left Shoulder")
	
	rightShoulder.Enabled = false
	leftShoulder.Enabled = false

	rightDragSocket.Parent = pRightArm
	leftDragSocket.Parent = pLeftArm

	local closeGrip : Attachment

	if (npcRightGrip.WorldPosition - (pRightGrip.WorldPosition + pLeftGrip.Position)).Magnitude < (npcLeftGrip.WorldPosition - (pRightGrip.WorldPosition + pLeftGrip.Position)).Magnitude then
		closeGrip = npcRightGrip
	else
		closeGrip = npcLeftGrip
	end
	rightDragSocket.Parent = pRightArm
	leftDragSocket.Parent = pLeftArm

	rightDragSocket.Attachment0 = pRightGrip
	rightDragSocket.Attachment1 = closeGrip

	leftDragSocket.Attachment0 = pLeftGrip
	leftDragSocket.Attachment1 = closeGrip
	
	local rightArmTorsoLink = Instance.new("Attachment")
	local leftArmTorsoLink = Instance.new("Attachment")
	local rightArmLink = Instance.new("Attachment")
	local leftArmLink = Instance.new("Attachment")

	rightArmTorsoLink.Parent = pTorso
	leftArmTorsoLink.Parent = pTorso
	rightArmLink.Parent = pRightArm
	leftArmLink.Parent = pLeftArm

	rightArmTorsoLink.CFrame = CFrame.new(1.3, 0.25, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1)
	rightArmLink.CFrame = CFrame.new(-0.2, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)

	leftArmTorsoLink.CFrame = CFrame.new(-1.3, 0.25, -1, -1, 0, 0, 0, -1, 0, 0, 0, 1)
	leftArmLink.CFrame = CFrame.new(0.2, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1)

	local rightArmSocket = Instance.new("BallSocketConstraint")
	local leftArmSocket = Instance.new("BallSocketConstraint")

	rightArmSocket.Parent = pRightArm
	leftArmSocket.Parent = pLeftArm

	rightArmSocket.Attachment0 = rightArmTorsoLink
	rightArmSocket.Attachment1 = rightArmLink

	leftArmSocket.Attachment0 = leftArmTorsoLink
	leftArmSocket.Attachment1 = leftArmLink
	
	rightDragSocket.LimitsEnabled = true
	leftDragSocket.LimitsEnabled = true

	for i,v in pairs(char:GetChildren()) do
		if v:IsA("BasePart") then
		--	v.CanCollide = true
		end
	end
	
	UIS.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.F then
			rightDragSocket:Destroy()
			leftDragSocket:Destroy()
			
			rightArmTorsoLink:Destroy()
			leftArmTorsoLink:Destroy()
			rightArmLink:Destroy()
			leftArmLink:Destroy()
			rightArmSocket:Destroy()
			leftArmSocket:Destroy()
			
			rightShoulder.Enabled = true
			leftShoulder.Enabled = true
			
			char:FindFirstChild("HumanoidRootPart"):FindFirstChild("ProximityPrompt").Enabled = true
		end
	end)
end)
3 Likes

Maybe slowing the player could help with it, not only would they be slower whilst dragging a body, but also that may help with the ragdoll flying towards the player. This is only a small help but ragdolls aren’t something that I’ve messed around with that much.

2 Likes

I really like the way you did this (not script wise but the actual way you grab and pull them), but either use CollisionGroups or what I’d recommend is adding NonCollisionConstraints so the player and body phase through each other during the duration of the drag.

2 Likes

thanks guys, do you think theres any way to make it as smooth as say hitman?

1 Like

weight and friction to the ragdoll body, slower character movement, limit the speed at which the player can rotate/change directions, lock camera closer

1 Like