Problem with ragdoll drag system

i have a problem with a ragdoll drag system i made. it seems to remove the players animations so that they’re like idle ig and it spasms out a bit. still looking for solutions on devforum rn but if theres anyone that knows how to fix this i’d really appreciate the help ty!

video:

script:

local event = game.ReplicatedStorage:WaitForChild("ropeEvent")

event.OnServerEvent:Connect(function(plr, otherchar)
	local mychar = plr.Character
local otherplr:Player = game.Players:GetPlayerFromCharacter(otherchar)

	if mychar.Humanoid.Health == 0 or otherchar.Humanoid.Health == 0 then return end

	local parts = {
		"charRope"
	}

	local chars = {
		mychar, -- my character
		otherchar -- another character
	}


	for _, part in ipairs(mychar:GetDescendants()) do
		if table.find(parts, part.Name) then return end
	end

	local function makeRope()
		local rope = Instance.new("RopeConstraint", mychar)
		rope.Name = "charRope"
		rope.Visible = true
		rope.Thickness = .15
		local at0 = Instance.new("Attachment", mychar.RightHand)
		at0.Name = "at0"
		local at1 = Instance.new("Attachment", otherchar.HumanoidRootPart)
		at1.Name = "at1"
		rope.Attachment0 = at0
		rope.Attachment1 = at1
		rope.Length = 10
		rope.Color = BrickColor.new("Really red")
		rope.WinchResponsiveness = 1
		rope.WinchEnabled = true
		
		local function ragdollotherPlr()
		local Humanoid:Humanoid = otherchar:WaitForChild("Humanoid")
		Humanoid.BreakJointsOnDeath = false

local otherplrParts = {
				"ragdollSocket",
				"ragdollAtt1",
				"ragdollAtt2"
}

for i, part in pairs(otherchar:GetDescendants()) do
	if table.find(otherplrParts, part.Name) then
		return end
 end

			for index, joint in pairs(otherchar:GetDescendants()) do
				if joint:IsA("Motor6D") then
					local socket = Instance.new("BallSocketConstraint")
					socket.Name = "ragdollSocket"
					local a1 = Instance.new("Attachment")
					a1.Name = "ragdollAtt1"
					local a2 = Instance.new("Attachment")
					a2.Name = "ragdollAtt2"
					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
					joint:Destroy()
					
				end
			end

		end
		
		ragdollotherPlr()

		mychar.Humanoid.Died:Connect(function()
			rope:Destroy()
			at1:Destroy()
			at0:Destroy()
		end)

		otherchar.Humanoid.Died:Connect(function()
			rope:Destroy()
			at1:Destroy()
			at0:Destroy()
		end)

	end

	makeRope()
end)
2 Likes

I have something similar, but separate for objects and tools.

Create a folder when the player joins that stores all the motor6Ds when you attach the rope.

Maybe also create a table to help keep track of individual joints, like

local playerJoints = {}

for i, motor in pairs(player.Character:GetDescendants()) do
      if motor:IsA('Motor6D') then
            motor.Parent = playerMotorFolder
            playerJoints[v.Parent.Name] = motor
      end
end

Replace the Motor6Ds with BallSocket or Hinge Constraints depending on how you want it to look.

When the rope is released, destroy or move the Constraints and put the Motor6Ds back.

for i, part in pairs(player.Character:GetChildren()) do
      if playerJoints[part.Name] then
            playerJoints[part.Name].Parent = part
            table.remove(playerJoints, part.Name)
      end
end

When the player leaves or the character dies, destroy the storage folder.

3 Likes

If the players need the BallSocketConstraints throughout the game why not just leave them in the playyer instead of Destroying them. This way they can just be Enabled = true or false when needed.

2 Likes

This is good, didn’t think of that lol. I’ll have to try that on my own

1 Like

@Scottifly @pixeldippz

hi guys, thank u so much for ur help. both of your points are very helpful and are 100% being considered. i completely forgot about disabling it so thanks for that. i updated the script.

ill be making the system togglable soon enough when i figure out how to make it toggle but the thing is right, when i spawn in it works, but when i respawn and then try it, it just bugs out.

vid:

2 Likes

Just use a variable

And I think what’s happening is the character your dragging has your name lmao

local RopeOn = false

--[[ when you click the button]]
RopeOn = not RopeOn

if RopeOn then
      -- add rope
      -- make joints
else
      -- break rope and joints
end

Then when the player dies, check if RopeOn is true and break/return the joints if so

Make sure to add one of these replies as a solution so you dont get any unwanted replies, btw lol

1 Like

yes. well i know its a db but the thing is i have a local script and i have no idea how to connect the db up to the script bc i have stuff like for loops all over the place.

this is what i got in lc:

local event = game.ReplicatedStorage:WaitForChild("ropeEvent")
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local ropeOn = false

mouse.Button1Down:Connect(function()
	local mouseTarget = mouse.Target
	ropeOn = true
	
	local target = mouseTarget:FindFirstAncestorOfClass("Model")
	local player = game.Players:GetPlayerFromCharacter(target)
	
	if player then
		local otherchar = player.Character
		
		if ropeOn then
		event:FireServer(otherchar, ropeOn)
		else
			if not ropeOn then
		event:FireServer(otherchar, ropeOn)
		end
		end
	end
end)

and for my script i got the ropeOn param up top:

Use

RopeOn = not RopeOn

Or

RopeOn = if RopeOn then false else true

Only set it on the server

Also, don’t use ReplicatedStorage for stuff that the server needs. People can hack it. Use ServerStorage instead.

ReplicatedStorage is best saved for events and RemoteFunctions. That way, if a hacker removes something from there, they’re only breaking the game for themselves lol

1 Like

ill defo keep that in mind. for the life of me tho i can never understand on how to get db’s to work

i got this but like it doesnt work:

if ropeOn == false then
	ropeOn = true
end

if ropeOn then
		local rope = Instance.new("RopeConstraint", mychar)
		rope.Name = "charRope"
		rope.Visible = true
		rope.Thickness = .15
		local at0 = Instance.new("Attachment", mychar.RightHand)
		at0.Name = "at0"
		local at1 = Instance.new("Attachment", otherchar.HumanoidRootPart)
		at1.Name = "at1"
		rope.Attachment0 = at0
		rope.Attachment1 = at1
		rope.Length = 10
		rope.Color = BrickColor.new("Really red")

It’s not exactly a debounce, a debounce is more like a cooldown for making sure not to run a certain thread while it’s already doing the same thing or busy with something else. Like if you have to wait 2 seconds between firing to pump your shotgun, you’d say something like

if debounceTime < 2 then return end

Or another debounce type is if you’re clicking a Gui button, so you don’t want to fire a weapon.

if mouseClickElsewhere then return end
-- mouseClickElsewhere is the "processed" in a UserInputService.InputBegan:Connect(function(input, processed)end)

This is more of a switch.

Use it exactly like this:

ropeOn = not ropeOn -- do this first
-- this switches to the opposite every time
-- if ropeOn is true, it sets it to false.
-- if ropeOn is false, it sets it to true.


-- THEN check whether it's now on or off
if ropeOn then
      -- if the rope is On then make the rope
else
      -- break the rope
end
1 Like

wsg man,

thanks for the info, i really appreciate all the help you’ve given me. hate to be bothering u but when i try to break the rope it doesnt recognise the “rope” variable i have here:

That’s because it came after the else statement.

Use

myChar:FindFirstDescendant(‘charRope’)

Also you should probably make ropeOn an attribute on your players or characters, so that it won’t automatically be true every time you call it.

And np lol

I can only help so much not being on your side of the screen with you tho lmao

Have you tried using Character.PrimaryPart:SetNetworkOwner(player: Player?)?
I’m assuming the issue is that the two clients fight for who runs the physics, making it feel unresponsive to the dragger.
After you ragdoll the other player and establish the constraints, try

otherChar.HumanoidRootPart:SetNetworkOwner(plr)

Then when unragdolling:

otherChar.HumanoidRootPart:SetNetworkOwner(nil)

The problem with that is then the other player will be unable to control their character, and if the constraints are made by the client, then the other players wouldn’t see the rope, and constraints wouldn’t exist for them without firing events to the server and then back to all clients, which is horrible for performance if there are a lot of players using the rope or similar tools at once.

The constraints are made on the server. They are replicated to all clients once created. Where did you get the impression the ropes were created on the clients?

I misread, but still, changing the network owner of character parts has an effect on local scripts and should be done with caution.

Only physically. The only affected thing would be the other players movement.

@pixeldippz @theseformasentence hey guys, thank u so much for the help. i cant seem to get it to toggle yet so im gonna look for more help but i appreciate everything you’ve done. thank u

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.